diff --git a/backend/toolshed/api/info.py b/backend/toolshed/api/info.py index 097cf9a..bb0124c 100644 --- a/backend/toolshed/api/info.py +++ b/backend/toolshed/api/info.py @@ -60,10 +60,12 @@ def list_availability_policies(request, format=None): # /availability_policies/ @authentication_classes([SignatureAuthentication]) def combined_info(request, format=None): # /info/ tags = [tag.name for tag in Tag.objects.all()] - properties = [property.name for property in Property.objects.all()] + properties = PropertySerializer(Property.objects.all(), many=True).data categories = [str(category) for category in Category.objects.all()] policies = ['private', 'friends', 'internal', 'public'] - return Response({'tags': tags, 'properties': properties, 'policies': policies, 'categories': categories}) + domains = [domain.name for domain in Domain.objects.filter(open_registration=True)] + return Response( + {'tags': tags, 'properties': properties, 'policies': policies, 'categories': categories, 'domains': domains}) urlpatterns = [ diff --git a/backend/toolshed/tests/test_api.py b/backend/toolshed/tests/test_api.py index 091f0a8..8a79370 100644 --- a/backend/toolshed/tests/test_api.py +++ b/backend/toolshed/tests/test_api.py @@ -36,6 +36,15 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper self.assertEqual(response.status_code, 200) self.assertEqual(response.json(), ['example.com']) + def test_policy_api_anonymous(self): + response = anonymous_client.get('/api/availability_policies/') + self.assertEqual(response.status_code, 403) + + def test_policy_api(self): + response = client.get('/api/availability_policies/', self.f['local_user1']) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.json(), ['private', 'friends', 'internal', 'public']) + def test_combined_api_anonymous(self): response = anonymous_client.get('/api/info/') self.assertEqual(response.status_code, 403) @@ -47,14 +56,6 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper self.assertEqual(response.json()['categories'], ['cat1', 'cat2', 'cat3', 'cat1/subcat1', 'cat1/subcat2', 'cat1/subcat1/subcat3']) self.assertEqual(response.json()['tags'], ['tag1', 'tag2', 'tag3']) - self.assertEqual(response.json()['properties'], ['prop1', 'prop2', 'prop3']) - - def test_policy_api_anonymous(self): - response = anonymous_client.get('/api/availability_policies/') - self.assertEqual(response.status_code, 403) - - def test_policy_api(self): - response = client.get('/api/availability_policies/', self.f['local_user1']) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.json(), ['private', 'friends', 'internal', 'public']) - + self.assertEqual([p['name'] for p in response.json()['properties']], ['prop1', 'prop2', 'prop3']) + self.assertEqual(response.json()['domains'], ['example.com']) + self.assertEqual(response.json()['policies'], ['private', 'friends', 'internal', 'public'])