Ejemplo n.º 1
0
    def test_get_list_returns_only_my_persons(self):
        # Set testing persons
        PersonFactory(user_created=self.user)
        user2 = UserFactory()
        PersonFactory(cpf=cpf(formatting=True), user_created=user2)
        # Test response and results
        response = self.client.get(self.url)
        eq_(response.status_code, status.HTTP_200_OK)

        persons = Person.objects.filter(user_created=self.user)
        serializer = PersonSerializer(persons, many=True)
        eq_(response.data["count"], 1)
        eq_(response.data["results"], serializer.data)
Ejemplo n.º 2
0
 def setUp(self):
     self.user = UserFactory()
     self.client.force_authenticate(user=self.user)
     self.company = CompanyFactory(user_created=self.user)
     self.company2 = CompanyFactory(cnpj=cnpj(formatting=True),
                                    user_created=self.user)
     self.person = PersonFactory(user_created=self.user)
     self.url = reverse("companies-detail", kwargs={"pk": self.company.pk})
Ejemplo n.º 3
0
 def setUp(self):
     self.person_data = model_to_dict(PersonFactory.build())
     self.person_data["cpf"] = self.person_data["_cpf"]
Ejemplo n.º 4
0
 def setUp(self):
     self.user = UserFactory()
     self.client.force_authenticate(user=self.user)
     self.person = PersonFactory(user_created=self.user)
     self.url = reverse("persons-detail", kwargs={"pk": self.person.pk})