chore(jarca-ledger): finalize approved batch docs, dashboard, and CI smoke updates
This commit is contained in:
@@ -49,3 +49,35 @@ def test_apply_categorization_rules_applies_all_matches_not_just_preview_sample(
|
||||
assert applied["applied_count"] == 150
|
||||
uncategorized = service.list_uncategorized_transactions(limit=200, db_path=db_path)
|
||||
assert uncategorized["count"] == 0
|
||||
|
||||
def test_single_category_rule_preview_and_apply_only_uncategorized(tmp_path):
|
||||
db_path = str(tmp_path / "ledger.sqlite3")
|
||||
seeded = service.seed_default_category_rules(db_path=db_path)
|
||||
assert seeded["success"] is True
|
||||
rules = service.list_category_rules(db_path=db_path)["rules"]
|
||||
mart_rule = next(r for r in rules if r["pattern"] == "이마트")
|
||||
|
||||
uncategorized = service.create_ledger_transaction(
|
||||
"2026-06-01", "expense", 10_000, merchant="이마트에브리데이", raw_summary="체크카드", db_path=db_path
|
||||
)["transaction"]
|
||||
categorized = service.create_ledger_transaction(
|
||||
"2026-06-02", "expense", 20_000, category="생활", subcategory="생필품", merchant="이마트24", raw_summary="체크카드", db_path=db_path
|
||||
)["transaction"]
|
||||
service.create_ledger_transaction(
|
||||
"2026-06-03", "expense", 30_000, merchant="알수없음", raw_summary="체크카드", db_path=db_path
|
||||
)
|
||||
|
||||
preview = service.preview_category_rule_matches(mart_rule["id"], db_path=db_path)
|
||||
assert preview["success"] is True
|
||||
assert preview["matched_count"] == 2
|
||||
assert preview["uncategorized_matched_count"] == 1
|
||||
assert len(preview["sample"]) == 2
|
||||
|
||||
applied = service.apply_category_rule(mart_rule["id"], db_path=db_path)
|
||||
assert applied["success"] is True
|
||||
assert applied["applied_count"] == 1
|
||||
|
||||
all_tx = service.list_ledger_transactions(limit=10, db_path=db_path)["transactions"]
|
||||
by_id = {tx["id"]: tx for tx in all_tx}
|
||||
assert by_id[uncategorized["id"]]["category"] == "식비"
|
||||
assert by_id[categorized["id"]]["category"] == "생활"
|
||||
|
||||
Reference in New Issue
Block a user