fix inconsistencies between policy api ant combined info api
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
j3d1 2024-03-07 00:44:58 +01:00
parent b3bae6f5ad
commit f2db5d9dad
4 changed files with 8 additions and 4 deletions

View file

@ -6,3 +6,5 @@
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions

View file

@ -61,9 +61,11 @@ def combined_info(request, format=None): # /info/
tags = [tag.name for tag in Tag.objects.all()]
properties = PropertySerializer(Property.objects.all(), many=True).data
categories = [str(category) for category in Category.objects.all()]
policies = ['private', 'friends', 'internal', 'public']
policies = InventoryItem.AVAILABILITY_POLICY_CHOICES
domains = [domain.name for domain in Domain.objects.filter(open_registration=True)]
return Response({'tags': tags, 'properties': properties, 'availability_policies': policies, 'categories': categories, 'domains': domains})
return Response(
{'tags': tags, 'properties': properties, 'availability_policies': policies, 'categories': categories,
'domains': domains})
urlpatterns = [

View file

@ -53,7 +53,8 @@ class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, Proper
def test_combined_api(self):
response = client.get('/api/info/', self.f['local_user1'])
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['availability_policies'], ['private', 'friends', 'internal', 'public'])
self.assertEqual(response.json()['availability_policies'], [['sell', 'Sell'], ['rent', 'Rent'], ['lend', 'Lend'],
['share', 'Share'], ['private', 'Private']])
self.assertEqual(response.json()['categories'],
['cat1', 'cat2', 'cat3', 'cat1/subcat1', 'cat1/subcat2', 'cat1/subcat1/subcat3'])
self.assertEqual(response.json()['tags'], ['tag1', 'tag2', 'tag3'])

View file

@ -375,7 +375,6 @@ class FriendRequestCombinedTestCase(UserTestMixin, ToolshedTestCase):
def setUp(self):
super().setUp()
self.prepare_users()
print(self.f)
def test_friend_request_combined(self):
befriender = self.f['local_user1']