diff --git a/core/tests.py b/core/tests.py
index f954857..3faf590 100644
--- a/core/tests.py
+++ b/core/tests.py
@@ -783,13 +783,14 @@ class InlineFiltersPairsContextTests(TestCase):
log.workers.add(self.w)
def test_pairs_context_key_populated(self):
- import json as _json
+ # The context value is a raw Python list of dicts; Django's
+ # |json_script filter handles the single JSON serialisation at
+ # template render time (no double-encoding).
self.client.login(username='admin-if', password='pass')
url = reverse('generate_report')
resp = self.client.get(url + '?from_month=2026-03&to_month=2026-04')
self.assertEqual(resp.status_code, 200)
- pairs_json = resp.context['project_team_pairs_json']
- pairs = _json.loads(pairs_json)
+ pairs = resp.context['project_team_pairs_json']
# Each entry has both project_id and team_id
for p in pairs:
self.assertIn('project_id', p)
@@ -801,7 +802,6 @@ class InlineFiltersPairsContextTests(TestCase):
def test_pairs_excludes_null_project_or_team(self):
"""Logs with null project or null team should not appear in pairs."""
- import json as _json
# Add a log with team=None
log = WorkLog.objects.create(
date=datetime.date(2026, 3, 2),
@@ -811,6 +811,39 @@ class InlineFiltersPairsContextTests(TestCase):
self.client.login(username='admin-if', password='pass')
resp = self.client.get(reverse('generate_report') + '?from_month=2026-03&to_month=2026-04')
- pairs = _json.loads(resp.context['project_team_pairs_json'])
+ pairs = resp.context['project_team_pairs_json']
# No pair should have team_id=None
self.assertTrue(all(p['team_id'] is not None for p in pairs))
+
+ def test_pairs_renders_as_valid_json_in_template(self):
+ """End-to-end: the rendered HTML must contain a single, valid JSON
+ array inside the
+ match = re.search(
+ r'',
+ html, re.DOTALL
+ )
+ self.assertIsNotNone(match, 'projectTeamPairs