예제 #1
0
    def test_organization_list_length(self):
        """Test organizations list length for admin user.

        Organizations are readable for everyone.
        """
        OrganizationFactory.create_batch(61)

        response = self.client.get('/api/organizations/')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 61)
예제 #2
0
    def test_organization_list_length(self):
        """Test organizations list length for user with organization.

        Organizations are readable for everyone.
        """
        OrganizationFactory.create_batch(75)

        response = self.client.get('/api/organizations/')

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # it's 76 here, as one organization is created when user is created:
        self.assertEqual(len(response.data), 76)
예제 #3
0
    def test_organization_list_fields(self):
        """Test list's fields of organization REST API endpoint."""
        OrganizationFactory.create_batch(56)

        response = self.client.get('/api/organizations/')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        for organization in response.data:
            self.assertIsInstance(organization.pop('address'), str)
            self.assertIsInstance(organization.pop('description'), str)
            self.assertIsInstance(organization.pop('id'), int)
            self.assertIsInstance(organization.pop('name'), str)
            self.assertIsInstance(organization.pop('slug'), str)
            self.assertIsInstance(organization.pop('url'), str)
            self.assertEqual(len(organization), 0)