From d09eaa4c211905ffbfa36b9a77c04a6c53527c42 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 14 May 2021 14:09:18 +0900 Subject: [PATCH] Add test cases for download catalog --- backend/api/tests/api/test_download.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 backend/api/tests/api/test_download.py diff --git a/backend/api/tests/api/test_download.py b/backend/api/tests/api/test_download.py new file mode 100644 index 00000000..dcafd66d --- /dev/null +++ b/backend/api/tests/api/test_download.py @@ -0,0 +1,21 @@ +from rest_framework import status +from rest_framework.reverse import reverse + +from ...models import DOCUMENT_CLASSIFICATION +from .utils import CRUDMixin, prepare_project + + +class TestDownloadCatalog(CRUDMixin): + + def setUp(self): + self.project = prepare_project(task=DOCUMENT_CLASSIFICATION) + self.url = reverse(viewname='download-format', args=[self.project.item.id]) + + def test_allows_project_admin_to_list_catalog(self): + response = self.assert_fetch(self.project.users[0], status.HTTP_200_OK) + for item in response.data: + self.assertIn('name', item) + + def test_denies_non_project_admin_to_list_catalog(self): + for member in self.project.users[1:]: + self.assert_fetch(member, status.HTTP_403_FORBIDDEN)