Skip to content

Commit

Permalink
Add helper to CourtGroups to determine if they should be displayed
Browse files Browse the repository at this point in the history
Some groups are 'dummy' ones (eg 'supreme court') which only contain a single court, and others should be displayed in the UI as headings (eg 'high court') - this adds a simple property to make this check when rendering the groups in the PUI. Happily 99% of the rest of what we need for the court heirarchy work was already there!
  • Loading branch information
timcowlishaw committed Oct 4, 2023
1 parent 96512d5 commit 86efb00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
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
13 changes: 11 additions & 2 deletions src/ds_caselaw_utils/test_courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import unittest
from datetime import date

from courts import Court, CourtGroup, CourtNotFoundException, CourtsRepository, courts
from ruamel.yaml import YAML

from .courts import Court, CourtNotFoundException, CourtsRepository, courts


class TestCourtsRepository(unittest.TestCase):
def test_loads_selectable_courts(self):
Expand Down Expand Up @@ -191,6 +190,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
2 changes: 1 addition & 1 deletion src/ds_caselaw_utils/test_neutral.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from .neutral import neutral_url
from neutral import neutral_url


class TestNeutralURL(unittest.TestCase):
Expand Down

0 comments on commit 86efb00

Please sign in to comment.