Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Sep 27, 2024
1 parent 7a10916 commit 901b578
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/ds_caselaw_utils/test_courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand All @@ -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)

Expand All @@ -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")

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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")
Expand All @@ -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")

Expand All @@ -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()])
Expand All @@ -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()])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 901b578

Please sign in to comment.