diff --git a/src/ds_caselaw_utils/courts.py b/src/ds_caselaw_utils/courts.py index 23d6b9b..4493319 100644 --- a/src/ds_caselaw_utils/courts.py +++ b/src/ds_caselaw_utils/courts.py @@ -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 diff --git a/src/ds_caselaw_utils/test_courts.py b/src/ds_caselaw_utils/test_courts.py index 474859f..d7dd444 100644 --- a/src/ds_caselaw_utils/test_courts.py +++ b/src/ds_caselaw_utils/test_courts.py @@ -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): @@ -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()