return more details in /info endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a461807edd
commit
64ee408082
2 changed files with 16 additions and 13 deletions
|
@ -60,10 +60,12 @@ def list_availability_policies(request, format=None): # /availability_policies/
|
||||||
@authentication_classes([SignatureAuthentication])
|
@authentication_classes([SignatureAuthentication])
|
||||||
def combined_info(request, format=None): # /info/
|
def combined_info(request, format=None): # /info/
|
||||||
tags = [tag.name for tag in Tag.objects.all()]
|
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()]
|
categories = [str(category) for category in Category.objects.all()]
|
||||||
policies = ['private', 'friends', 'internal', 'public']
|
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 = [
|
urlpatterns = [
|
||||||
|
|
|
@ -36,6 +36,15 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json(), ['example.com'])
|
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):
|
def test_combined_api_anonymous(self):
|
||||||
response = anonymous_client.get('/api/info/')
|
response = anonymous_client.get('/api/info/')
|
||||||
self.assertEqual(response.status_code, 403)
|
self.assertEqual(response.status_code, 403)
|
||||||
|
@ -47,14 +56,6 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper
|
||||||
self.assertEqual(response.json()['categories'],
|
self.assertEqual(response.json()['categories'],
|
||||||
['cat1', 'cat2', 'cat3', 'cat1/subcat1', 'cat1/subcat2', 'cat1/subcat1/subcat3'])
|
['cat1', 'cat2', 'cat3', 'cat1/subcat1', 'cat1/subcat2', 'cat1/subcat1/subcat3'])
|
||||||
self.assertEqual(response.json()['tags'], ['tag1', 'tag2', 'tag3'])
|
self.assertEqual(response.json()['tags'], ['tag1', 'tag2', 'tag3'])
|
||||||
self.assertEqual(response.json()['properties'], ['prop1', 'prop2', 'prop3'])
|
self.assertEqual([p['name'] for p in response.json()['properties']], ['prop1', 'prop2', 'prop3'])
|
||||||
|
self.assertEqual(response.json()['domains'], ['example.com'])
|
||||||
def test_policy_api_anonymous(self):
|
self.assertEqual(response.json()['policies'], ['private', 'friends', 'internal', 'public'])
|
||||||
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'])
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue