summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2026-01-12 18:27:56 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2026-01-12 18:27:56 +0100
commit43339caea0a1bc7125740746c568fbe536c96d2e (patch)
treed710bb1bff6187bd8389e72641e545326f7a8df7 /ishtar_common
parent555868ac554938ce90e181b77971286d7170fdc6 (diff)
downloadIshtar-43339caea0a1bc7125740746c568fbe536c96d2e.tar.bz2
Ishtar-43339caea0a1bc7125740746c568fbe536c96d2e.zip
✅ basic tests for all statistics modality
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/tests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 7582bf163..35184d561 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -266,6 +266,36 @@ class SearchText:
self.assertEqual(res["recordsTotal"], expected_result, msg=msg)
+class StatisticsTest:
+ MODEL = None
+ SEARCH_URL = None
+
+ def test_base_statistics(self):
+ if not self.MODEL:
+ raise NotImplementedError("MODEL attribute must be set on the class")
+ if not self.SEARCH_URL:
+ raise NotImplementedError("SEARCH_URL attribute must be set on the class")
+ c = Client()
+
+ base_extra = "json-stats?submited=1"
+ response = c.get(reverse(self.SEARCH_URL) + base_extra)
+ # empty when not allowed
+ if response.status_code == 200:
+ self.assertEqual(response.status_code, 200)
+ content = json.loads(response.content.decode("utf-8"))
+ self.assertEqual(content, [])
+ c.login(username=self.username, password=self.password)
+
+ base_extra += "&stats_sum_variable=pk&stats_modality_1="
+ for modality in self.MODEL.STATISTIC_MODALITIES_OPTIONS:
+ response = c.get(reverse(self.SEARCH_URL) + base_extra + modality)
+ self.assertEqual(response.status_code, 200)
+ # only verify a response is sent
+ # TODO: check more
+ content = json.loads(response.content.decode("utf-8"))
+ self.assertTrue(len(content["data"]) > 0)
+
+
class CommandsTestCase(TestCase):
fixtures = [LIB_BASE_PATH + "ishtar_common/fixtures/test_towns.json"]