From f687d82999efbf05ca466c32b81a096f00fc7b95 Mon Sep 17 00:00:00 2001 From: Yohanna Lisnichuk Date: Fri, 3 Nov 2023 14:52:32 -0300 Subject: [PATCH] fix tests --- tests/exporter/test_views.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/exporter/test_views.py b/tests/exporter/test_views.py index d37e26e0..6f108406 100644 --- a/tests/exporter/test_views.py +++ b/tests/exporter/test_views.py @@ -7,32 +7,30 @@ @override_settings(EXPORTER_DIR=os.path.join("tests", "fixtures")) class ViewsTests(TestCase): def test_download_export_invalid_suffix(self): - with self.assertNumQueries(0): - response = Client().get("/api/download_export?suffix=invalid") + with self.assertNumQueries(1): + response = Client().get("/publication/1/download?name=invalid") self.assertEqual(response.status_code, 400) self.assertEqual(response.content, b"Suffix not recognized") def test_download_export_empty_parameter(self): - for parameter in ("job_id", "year"): - with self.subTest(parameter=parameter): - with self.assertNumQueries(0): - response = Client().get(f"/api/download_export?suffix=jsonl.gz&{parameter}=") + with self.assertNumQueries(1): + response = Client().get("/publication/1/download?name=") - self.assertEqual(response.status_code, 404) - self.assertEqual(response.content, b"File not found") + self.assertEqual(response.status_code, 404) + self.assertEqual(response.content, b"File not found") def test_download_export_waiting(self): - with self.assertNumQueries(0): - response = Client().get("/api/download_export?suffix=jsonl.gz&year=2000&job_id=0") + with self.assertNumQueries(1): + response = Client().get("/publication/1/download?name=2000.jsonl.gz") self.assertEqual(response.status_code, 404) self.assertEqual(response.content, b"File not found") @patch("exporter.util.Export.lockfile", new_callable=PropertyMock) def test_download_export_running(self, exists): - with self.assertNumQueries(0): - response = Client().get("/api/download_export?suffix=jsonl.gz&year=2000&job_id=1") + with self.assertNumQueries(1): + response = Client().get("/publication/1/download?name=2000.jsonl.gz") self.assertEqual(response.status_code, 404) self.assertEqual(response.content, b"File not found") @@ -44,9 +42,9 @@ def test_download_export_completed(self): ("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), ): with self.subTest(suffix=suffix): - with self.assertNumQueries(0): + with self.assertNumQueries(1): response = Client().get( - f"/api/download_export?suffix={suffix}&year=2000&job_id=1&spider=abc", + f"/publication/1/download?name=2000.{suffix}", HTTP_ACCEPT_ENCODING="gzip", )