File size: 1,385 Bytes
6f5156a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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 = (
'<div><a href="/akn/gh/judgment/ghasc/2024/12/eng@2024-03-19" '
'data-key-link="document">Foo v Bar [2024] GHASC 12 (19 March 2024)</a></div>'
)
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)",
)
]
|