Commit f5d044eb authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

Fix test and add url namespaces

parent 4352eea6
Pipeline #13527 passed with stages
in 2 minutes and 1 second
......@@ -12,7 +12,7 @@ class TestAccounts(APITestCase):
def test_obtain_jwt(self):
# create an inactive user
url = reverse('api-jwt-auth')
url = reverse('auth:api-jwt-auth')
u = User.objects.create_user(username='user', email='user@foo.com', password='pass')
u.is_active = False
u.save()
......@@ -39,7 +39,7 @@ class TestAccounts(APITestCase):
payload = jwt_payload_handler(user)
token = jwt_encode_handler(payload)
verify_url = reverse('api-jwt-verify')
verify_url = reverse('auth:api-jwt-verify')
credentials = {
'token': token
}
......
......@@ -7,10 +7,10 @@ from metagenedb.api.catalog.views import GeneViewSet, gene_length
api_router = DefaultRouter()
api_router.register(r'genes', GeneViewSet, 'genes')
api_router.register(r'genes', GeneViewSet, base_name='genes')
urlpatterns = [
re_path(r'^gene_length$', gene_length, name='gene_length'),
url(r'v1/', include(api_router.urls))
url(r'v1/', include((api_router.urls, 'v1'), namespace='v1'))
]
......@@ -14,7 +14,7 @@ class TestGenes(TestCase):
Unauthenticated users should be able to access genes
@TODO make unaccessible
"""
url = reverse('genes')
url = reverse('catalog:v1:genes-list')
resp = self.client.get(url)
self.assertEqual(resp.status_code, status.HTTP_200_OK)
......@@ -32,6 +32,6 @@ class TestGenes(TestCase):
payload = jwt_payload_handler(user)
token = jwt_encode_handler(payload)
url = reverse('genes')
url = reverse('catalog:v1:genes-list')
resp = self.client.get(url, format='json', HTTP_AUTHORIZATION=f"JWT {token}")
self.assertEqual(resp.status_code, status.HTTP_200_OK)
......@@ -2,6 +2,6 @@ from django.urls import include, path
urlpatterns = [
path('auth/', include('metagenedb.api.accounts.urls')),
path('catalog/', include('metagenedb.api.catalog.urls'))
path('auth/', include(('metagenedb.api.accounts.urls', 'auth'), namespace='auth')),
path('catalog/', include(('metagenedb.api.catalog.urls', 'catalog'), namespace='catalog'))
]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment