From 901b578fdcb310f3b67f006e0560b7203dafc5e3 Mon Sep 17 00:00:00 2001 From: David McKee Date: Fri, 27 Sep 2024 11:43:45 +0100 Subject: [PATCH] fix tests --- src/ds_caselaw_utils/test_courts.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ds_caselaw_utils/test_courts.py b/src/ds_caselaw_utils/test_courts.py index adceb71..4a9b100 100644 --- a/src/ds_caselaw_utils/test_courts.py +++ b/src/ds_caselaw_utils/test_courts.py @@ -33,9 +33,10 @@ def test_loads_all_courts_without_jurisdictions(self): { "name": "court_group", "display_name": "court group 1", - "courts": [{"name": "court1", "jurisdictions": [{"name": "jurisdiction1"}]}], + "courts": [{"name": "court1", "jurisdictions": [{"name": "jurisdiction1", "code": "code"}]}], } ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) courts = repo.get_all() self.assertIn("court1", [c.name for c in courts]) @@ -46,7 +47,7 @@ def test_loads_all_courts_with_jurisdictions(self): { "name": "court_group", "display_name": "court group 1", - "courts": [{"name": "court1", "jurisdictions": [{"name": "jurisdiction1"}]}], + "courts": [{"name": "court1", "jurisdictions": [{"name": "jurisdiction1", "code": "code"}]}], } ] data = make_court_repo_valid(data) @@ -74,6 +75,7 @@ def test_loads_selectable_courts(self): "courts": [{"name": "court3", "selectable": False}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) selectable = repo.get_selectable() self.assertIn("court1", [c.name for c in selectable]) @@ -104,6 +106,7 @@ def test_loads_listable_courts(self): "courts": [{"name": "court3", "listable": False}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) groups = repo.get_listable_groups() self.assertIn("court group 1", [g.name for g in groups]) @@ -123,6 +126,7 @@ def test_loads_court_by_param(self): "courts": [{"param": "court2", "name": "Court 2"}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertEqual("Court 2", repo.get_by_param(CourtParam("court2")).name) @@ -137,6 +141,7 @@ def test_raises_on_unknown_court_param(self): "courts": [{"param": "court2", "name": "Court 2"}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertRaises(CourtNotFoundException, repo.get_by_param, "court3") @@ -151,6 +156,7 @@ def test_loads_court_by_code(self): "courts": [{"code": "court2", "name": "Court 2"}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertEqual("Court 2", repo.get_by_code(CourtCode("court2")).name) @@ -167,6 +173,7 @@ def test_loads_court_with_jurisdiction_by_code(self): ], } ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertEqual("Court 1 – Jurisdiction 1", repo.get_by_code(CourtCode("court1/jurisdiction1")).name) @@ -183,6 +190,7 @@ def test_raises_error_for_nonexistent_jurisdictions(self): ], } ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertRaises(CourtNotFoundException, repo.get_by_code, "court1/jurisdiction2") self.assertRaises(CourtNotFoundException, repo.get_by_code, "court2/jurisdiction1") @@ -198,6 +206,7 @@ def test_raises_on_unknown_court_code(self): "courts": [{"code": "court2", "name": "Court 2"}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertRaises(CourtNotFoundException, repo.get_by_code, "court3") @@ -217,6 +226,7 @@ def test_returns_listable_courts(self): "courts": [{"param": "court3", "listable": True, "name": "Court 3"}], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertIn("court1", [c.canonical_param for c in repo.get_listable_courts()]) self.assertNotIn("court2", [c.canonical_param for c in repo.get_listable_courts()]) @@ -240,6 +250,7 @@ def test_returns_listable_tribunals(self): ], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) self.assertNotIn("court1", [c.canonical_param for c in repo.get_listable_tribunals()]) self.assertNotIn("court2", [c.canonical_param for c in repo.get_listable_tribunals()]) @@ -273,6 +284,7 @@ def test_returns_grouped_selectable_courts(self): ], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) groups = repo.get_grouped_selectable_courts() self.assertIn("Court group", [g.name for g in groups]) @@ -309,6 +321,7 @@ def test_returns_grouped_selectable_tribunals(self): ], }, ] + data = make_court_repo_valid(data) repo = CourtsRepository(data) groups = repo.get_grouped_selectable_tribunals() self.assertIn("Tribunal group", [g.name for g in groups])