Added to test the search in the ReportTestCase test case.

This commit is contained in:
依瑪貓 2023-04-09 09:28:11 +08:00
parent 7ca08d6cc8
commit 51f0185bcf

View File

@ -126,6 +126,12 @@ class ReportTestCase(unittest.TestCase):
response = client.get(f"{PREFIX}/unapplied/{Accounts.PAYABLE}?as=csv") response = client.get(f"{PREFIX}/unapplied/{Accounts.PAYABLE}?as=csv")
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
response = client.get(f"{PREFIX}/search?q=Airplane")
self.assertEqual(response.status_code, 403)
response = client.get(f"{PREFIX}/search?q=Airplane&as=csv")
self.assertEqual(response.status_code, 403)
def test_viewer(self) -> None: def test_viewer(self) -> None:
"""Test the permission as viewer. """Test the permission as viewer.
@ -207,6 +213,14 @@ class ReportTestCase(unittest.TestCase):
self.assertEqual(response.headers["Content-Type"], self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8") "text/csv; charset=utf-8")
response = client.get(f"{PREFIX}/search?q=Airplane")
self.assertEqual(response.status_code, 200)
response = client.get(f"{PREFIX}/search?q=Airplane&as=csv")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8")
def test_editor(self) -> None: def test_editor(self) -> None:
"""Test the permission as editor. """Test the permission as editor.
@ -288,6 +302,14 @@ class ReportTestCase(unittest.TestCase):
self.assertEqual(response.headers["Content-Type"], self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8") "text/csv; charset=utf-8")
response = self.client.get(f"{PREFIX}/search?q=Airplane")
self.assertEqual(response.status_code, 200)
response = self.client.get(f"{PREFIX}/search?q=Airplane&as=csv")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8")
def test_empty_db(self) -> None: def test_empty_db(self) -> None:
"""Tests the empty database. """Tests the empty database.
@ -367,3 +389,11 @@ class ReportTestCase(unittest.TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["Content-Type"], self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8") "text/csv; charset=utf-8")
response = self.client.get(f"{PREFIX}/search?q=Airplane")
self.assertEqual(response.status_code, 200)
response = self.client.get(f"{PREFIX}/search?q=Airplane&as=csv")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["Content-Type"],
"text/csv; charset=utf-8")