コード例 #1
0
 def test_edit_project_view_with_only_required_fields_job(self):
     """
 Project edit job with only required fields and no availabilites.
 """
     factory = APIRequestFactory()
     project = {
         'name': "Name",
         'details': 'This needs to be big',
         'description': 'This needs to be big',
         'responsible': 'Marjori',
         'phone': '123123',
         'email': '*****@*****.**',
         'skills': [1],
         'causes': [2],
         'job': {
             'start_date': 20140416,
             'end_date': 20140417
         },
         'nonprofit': 1
     }
     n = self.create_nonprofit()
     p = Project(nonprofit=n,
                 name=project['name'],
                 slug="name",
                 details=project['details'])
     p.save()
     project['id'] = p.id
     request = factory.put("/save/project/", {'project': project})
     force_authenticate(request, user=n.user)
     response = views.save_project(request)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
コード例 #2
0
 def test_edit_projec_view_with_changing_roles(self):
     """
 Project edit with deleting and adding new roles.
 """
     project = {
         'name': "Name",
         'details': 'This needs to be big',
         'description': 'This needs to be big',
         'responsible': 'Marjori',
         'phone': '123123',
         'email': '*****@*****.**',
         'skills': [1],
         'causes': [2],
         'job': {
             'start_date': 20140416,
             'end_date': 20140417
         },
         'nonprofit': 1
     }
     factory = APIRequestFactory()
     n = self.create_nonprofit()
     r = Role(name="role name")
     r.save()
     p = Project(nonprofit=n, name='name', slug="name")
     p.save()
     p.roles.add(r)
     project['id'] = p.id
     request = factory.put("/save/project/", {'project': project})
     force_authenticate(request, user=n.user)
     response = views.save_project(request)
     newP = Project.objects.get(id=p.id)
     self.assertEqual(newP.roles.count(), 0)
     self.assertEquals(response.status_code, status.HTTP_201_CREATED)
コード例 #3
0
 def test_apply_creation(self):
     """
 Tests Apply.
 """
     u = User(name="Voluntario", slug="voluntario")
     u.save()
     v = Volunteer(user=u)
     v.save()
     p = Project(name="Project")
     a = Apply(status=ApplyStatus(), volunteer=v, project=p)
     self.assertTrue(isinstance(a, Apply))
     self.assertEqual(a.__unicode__(), "[False] Voluntario - Project")
コード例 #4
0
 def create_project(self):
     u = User(email="*****@*****.**", name="what", slug="hahah")
     u.save()
     n = Nonprofit(user=u, name="hahah")
     n.save()
     from random import randint
     random = randint(1, 100)
     project = Project(nonprofit=n, name='name' + str(random))
     project.nonprofit = n
     project.save()
     project.job = Job(start_date=datetime.now().replace(
         tzinfo=pytz.timezone("America/Sao_Paulo")),
                       end_date=datetime.now().replace(
                           tzinfo=pytz.timezone("America/Sao_Paulo")))
     project.job.save()
     return project
コード例 #5
0
 def test_comment_deletion(self):
     """
 Tests Comment deletion.
 """
     u1 = User(email="test", slug="user1")
     u1.save()
     n = Nonprofit(user=u1)
     n.save()
     p = Project(name="Project 1", nonprofit=n)
     p.save()
     u = User(email="*****@*****.**", slug="email")
     u.save()
     c = self.create_comment(p, u, "Comment nro 1")
     c.save()
     c.delete()
     self.assertTrue(c.deleted)
     self.assertTrue(c.deleted_date)
コード例 #6
0
 def test_comment_creation(self):
     """
 Tests Comment creation.
 """
     u1 = User(email="test", slug="user1")
     u1.save()
     n = Nonprofit(user=u1)
     n.save()
     p = Project(name="Project 1", nonprofit=n)
     p.save()
     u = User(email="*****@*****.**", slug="email")
     u.save()
     c = self.create_comment(p, u, "Comment nro 1")
     c.save()
     now = datetime.utcnow().replace(
         tzinfo=pytz.timezone("America/Sao_Paulo"))
     self.assertTrue(isinstance(c, Comment))
     self.assertEqual(c.__unicode__(),
                      "(Project 1) [email protected]: Comment nro 1")
     self.assertTrue(datesAreEqual(c.created_date, now))
コード例 #7
0
 def create_project(self, nonprofit, name):
     project = Project(nonprofit=nonprofit, name=name)
     project.save()
     return project