def test_create_volunteer_view(self): """ Ensure we can create a new volunteer. """ factory = APIRequestFactory() request = factory.post("/create/volunteer/", {"slug": self.slug, "email": self.email, "password": self.password}) response = views.create_volunteer(request) self.assertEqual(response.data, {'detail': 'Volunteer succesfully created.'}) self.assertEqual(response.status_code, status.HTTP_201_CREATED) user = User.objects.get(email=self.email) volunteer = user.volunteer self.assertEqual(volunteer.user.email, user.email)
def test_create_volunteer_view(self): """ Ensure we can create a new volunteer. """ factory = APIRequestFactory() request = factory.post("/create/volunteer/", { "slug": self.slug, "email": self.email, "password": self.password }) response = views.create_volunteer(request) self.assertEqual(response.data, {'detail': 'Volunteer succesfully created.'}) self.assertEqual(response.status_code, status.HTTP_201_CREATED) user = User.objects.get(email=self.email) volunteer = user.volunteer self.assertEqual(volunteer.user.email, user.email)
def test_create_volunteer_with_address_view(self): """ Ensure we can create a new volunteer with address """ s = State(name="User state") s.save() c = City(id=990, name="User city", state=s) c.save() factory = APIRequestFactory() request = factory.post("/create/volunteer/", {"slug": self.slug, "email": self.email, "password": self.password, 'address': {'addr': {'formatted_address': 'R. Capote Valente, 701, São Paulo'}, 'typed_address2': 'Complemento'}}) response = views.create_volunteer(request) self.assertEqual(response.data, {'detail': 'Volunteer succesfully created.'}) self.assertEqual(response.status_code, status.HTTP_201_CREATED) user = User.objects.get(email=self.email) volunteer = user.volunteer self.assertEqual(volunteer.user.email, user.email) self.assertEqual(user.googleaddress.typed_address, u"R. Capote Valente, 701, São Paulo") self.assertEqual(user.googleaddress.typed_address2, u"Complemento")