from legex.models.base import Case from legex.scrapers.gh import GHScraper, _CRIMINAL_RE def _case(title: str) -> Case: return Case(case_id="[2024] GHASC 1", jurisdiction="gh", metadata={"title": title}) def test_criminal_re_matches_classic(): assert _CRIMINAL_RE.match("Republic v Mensah") assert _CRIMINAL_RE.match("The Republic v Mensah") def test_criminal_re_matches_vrs(): assert _CRIMINAL_RE.match("Republic vrs Owusu") assert _CRIMINAL_RE.match("The Republic vrs. Owusu") def test_criminal_re_skips_civil(): assert not _CRIMINAL_RE.match("OWUSU & anor v MAPUTO & 3 ors") assert not _CRIMINAL_RE.match("In Re Estate of X") def test_civil_filter_drops_criminal(): cases = [_case("Republic v Smith"), _case("Mensah v Owusu")] kept = GHScraper.civil_filter(cases) assert [c.metadata["title"] for c in kept] == ["Mensah v Owusu"] def test_parse_listing_picks_up_link(): html = ( '
' ) entries = list(GHScraper._parse_listing(html)) assert entries == [ ( "/akn/gh/judgment/ghasc/2024/12/eng@2024-03-19", "2024", "12", "2024-03-19", "Foo v Bar [2024] GHASC 12 (19 March 2024)", ) ]