Skip to content

Commit

Permalink
Merge pull request #74 from nationalarchives/feature/court-groups
Browse files Browse the repository at this point in the history
Add helper to CourtGroups to determine if they should be displayed
  • Loading branch information
timcowlishaw authored Oct 4, 2023
2 parents 96512d5 + 887f541 commit 935829b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ds_caselaw_utils/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def __init__(self, name, courts):
self.name = name
self.courts = courts

@property
def display_heading(self):
return self.name is not None


class CourtNotFoundException(Exception):
pass
Expand Down
12 changes: 11 additions & 1 deletion src/ds_caselaw_utils/test_courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ruamel.yaml import YAML

from .courts import Court, CourtNotFoundException, CourtsRepository, courts
from .courts import Court, CourtGroup, CourtNotFoundException, CourtsRepository, courts


class TestCourtsRepository(unittest.TestCase):
Expand Down Expand Up @@ -191,6 +191,16 @@ def test_end_year_default(self):
self.assertEqual(date.today().year, court.end_year)


class TestCourtGroup(unittest.TestCase):
def test_display_heading_when_has_display_name(self):
group = CourtGroup("name", [])
assert group.display_heading

def test_dont_display_heading_when_no_display_name(self):
group = CourtGroup(None, [])
assert not group.display_heading


class TestCourts(unittest.TestCase):
def test_loads_court_yaml(self):
yaml = YAML()
Expand Down

0 comments on commit 935829b

Please sign in to comment.