コード例 #1
0
 def setUp(self):
     self.user = UserFactory()
     self.person = PersonFactory()
     self.client.force_authenticate(user=self.user)
     self.url = reverse("ownerships-list")
     self.ownership_data = factory.build(dict, FACTORY_CLASS=OwnershipFactory)
     self.ownership_data["owner"] = self.person.pk
コード例 #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})
コード例 #3
0
    def test_get_list_returns_only_my_created_ownerships(self):
        # Set testing ownerships
        OwnershipFactory(owner=self.person, user_created=self.user)
        user2 = UserFactory()
        OwnershipFactory(owner=self.person, user_created=user2)
        # Test response and results
        response = self.client.get(self.url)
        eq_(response.status_code, status.HTTP_200_OK)

        ownerships = Ownership.objects.filter(owner=self.person, user_created=self.user)
        serializer = OwnershipSerializer(ownerships, many=True)
        eq_(response.data["count"], 1)
        eq_(response.data["results"], serializer.data)
コード例 #4
0
    def test_get_list_returns_only_my_companies(self):
        # Set testing companies
        CompanyFactory(user_created=self.user)
        user2 = UserFactory()
        CompanyFactory(cnpj=cnpj(formatting=True), user_created=user2)
        # Test response and results
        response = self.client.get(self.url)
        eq_(response.status_code, status.HTTP_200_OK)

        companies = Company.objects.filter(user_created=self.user)
        serializer = CompanySerializer(companies, many=True)
        eq_(response.data["count"], 1)
        eq_(response.data["results"], serializer.data)
コード例 #5
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)
コード例 #6
0
 def setUp(self):
     self.user = UserFactory()
     self.person = PersonFactory()
     self.client.force_authenticate(user=self.user)
     self.ownership = OwnershipFactory(owner=self.person, user_created=self.user)
     self.url = reverse("ownerships-detail", kwargs={"pk": self.ownership.pk})
コード例 #7
0
 def setUp(self):
     self.user = UserFactory()
     self.client.force_authenticate(user=self.user)
     self.url = reverse("companies-list")
     self.company_data = factory.build(dict, FACTORY_CLASS=CompanyFactory)
コード例 #8
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})
コード例 #9
0
 def setUp(self):
     self.user = UserFactory()
     self.client.force_authenticate(user=self.user)
     self.url = reverse("persons-list")
     self.person_data = factory.build(dict, FACTORY_CLASS=PersonFactory)