예제 #1
0
 def test_list_memberships(self, client, org_name, expected_count):
     org = Organization.objects.get(name=org_name)
     MembershipFactory.create_batch(3, group__organization=org)
     response = client.get(self.url)
     results = response.json()['results']
     assert response.status_code == HTTP_200_OK, response.content
     assert len(results) == expected_count
예제 #2
0
 def test_list_users(self, client, org_name, expected_count):
     org = Organization.objects.get(name=org_name)
     # Two users without memberships
     without_memberships = UserFactory.create_batch(2)
     # Three additional users with memberships
     with_memberships = [m.user for m in MembershipFactory.create_batch(3, group__organization=org)]
     UserOrganizationMappingFactory.create_for(
         org,
         users=without_memberships + with_memberships,
     )
     response = client.get(self.url)
     results = response.json()['results']
     assert response.status_code == HTTP_200_OK, response.content
     assert len(results) == expected_count