add /api/version
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
j3d1 2023-10-23 13:06:22 +02:00
parent 49de2decca
commit cc0bdc0472
4 changed files with 56 additions and 14 deletions

View file

@ -1,25 +1,30 @@
from django.test import Client
from authentication.tests import UserTestMixin, SignatureAuthClient, ToolshedTestCase
from toolshed.models import Category, Tag, Property
from backend import settings
from toolshed.tests import CategoryTestMixin, TagTestMixin, PropertyTestMixin
anonymous_client = Client()
client = SignatureAuthClient()
class CombinedApiTestCase(UserTestMixin, ToolshedTestCase):
class CombinedApiTestCase(UserTestMixin, CategoryTestMixin, TagTestMixin, PropertyTestMixin, ToolshedTestCase):
def setUp(self):
super().setUp()
self.prepare_users()
self.f['cat1'] = Category.objects.create(name='cat1')
self.f['cat2'] = Category.objects.create(name='cat2')
self.f['cat3'] = Category.objects.create(name='cat3')
self.f['tag1'] = Tag.objects.create(name='tag1')
self.f['tag2'] = Tag.objects.create(name='tag2')
self.f['tag3'] = Tag.objects.create(name='tag3')
self.f['prop1'] = Property.objects.create(name='prop1')
self.f['prop2'] = Property.objects.create(name='prop2')
self.f['prop3'] = Property.objects.create(name='prop3')
self.prepare_categories()
self.prepare_tags()
self.prepare_properties()
def test_version_anonymous(self):
response = anonymous_client.get('/api/version/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {'version': settings.TOOLSHED_VERSION})
def test_version_authenticated(self):
response = client.get('/api/version/', self.f['local_user1'])
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {'version': settings.TOOLSHED_VERSION})
def test_domains_anonymous(self):
response = anonymous_client.get('/api/domains/')
@ -39,7 +44,8 @@ class CombinedApiTestCase(UserTestMixin, ToolshedTestCase):
response = client.get('/api/info/', self.f['local_user1'])
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()['policies'], ['private', 'friends', 'internal', 'public'])
self.assertEqual(response.json()['categories'], ['cat1', 'cat2', 'cat3'])
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'])
@ -51,3 +57,4 @@ class CombinedApiTestCase(UserTestMixin, ToolshedTestCase):
response = client.get('/api/availability_policies/', self.f['local_user1'])
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), ['private', 'friends', 'internal', 'public'])

View file

@ -1,5 +1,4 @@
from authentication.tests import SignatureAuthClient, UserTestMixin, ToolshedTestCase
from toolshed.models import Category
from toolshed.tests import CategoryTestMixin
client = SignatureAuthClient()