examples: regex pre-filter (MONEY_RE + LOCATION_RE)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
c9bdf537ac
commit
a378c7256e
2 changed files with 100 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import pytest
|
|||
from pydantic import ValidationError
|
||||
|
||||
from fire_planner.examples import ExtractedExample, FiStatus, RawPost, SummaryStats
|
||||
from fire_planner.examples.filters import is_candidate
|
||||
|
||||
|
||||
def test_raw_post_minimal() -> None:
|
||||
|
|
@ -44,3 +45,38 @@ def test_extracted_example_fi_status_enum() -> None:
|
|||
def test_summary_stats_optional_fields() -> None:
|
||||
s = SummaryStats(median=None, p25=None, p75=None)
|
||||
assert s.median is None
|
||||
|
||||
|
||||
def _post(title: str, body: str = "") -> RawPost:
|
||||
return RawPost(
|
||||
reddit_id="x",
|
||||
source_sub="s",
|
||||
url="u",
|
||||
title=title,
|
||||
body=body,
|
||||
created_at=date(2026, 1, 1),
|
||||
)
|
||||
|
||||
|
||||
def test_filter_keeps_money_plus_location() -> None:
|
||||
assert is_candidate(_post("Hit £1m living in Lisbon, Portugal"))
|
||||
|
||||
|
||||
def test_filter_drops_money_without_location() -> None:
|
||||
assert not is_candidate(_post("Hit £1m, feels great!"))
|
||||
|
||||
|
||||
def test_filter_drops_location_without_money() -> None:
|
||||
assert not is_candidate(_post("Moving to Lisbon next year"))
|
||||
|
||||
|
||||
def test_filter_dollar_signs_count() -> None:
|
||||
assert is_candidate(_post("$1.2M net worth, retired in Chiang Mai"))
|
||||
|
||||
|
||||
def test_filter_recognises_net_worth_keyword() -> None:
|
||||
assert is_candidate(_post("Net worth update — now in Bali, Indonesia"))
|
||||
|
||||
|
||||
def test_filter_keyword_match_is_case_insensitive() -> None:
|
||||
assert is_candidate(_post("PORTFOLIO milestone reached, settled in PHILIPPINES"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue