feat: stabilize category rule operations

approve dcy-001 and add REQ/BAT evidence

pass selected DB path through Streamlit rule actions

expose delete_category_rule MCP tool

add category rule deletion regression
This commit is contained in:
Jarca
2026-06-27 00:02:06 +09:00
parent 97115f6acf
commit 0f881b245f
12 changed files with 459 additions and 5 deletions
+31
View File
@@ -103,3 +103,34 @@ def test_update_category_rule_allows_condition_edits(tmp_path):
assert rule["amount_max"] == 150000
assert rule["day_of_month"] == 10
assert rule["active"] is False
def test_delete_category_rule_removes_rule_and_reports_missing_ids(tmp_path):
db_path = str(tmp_path / "ledger.sqlite3")
service.health_check(db_path)
created = service.create_category_rule(
match_field="merchant",
match_type="contains",
pattern="삭제대상",
transaction_type="expense",
category="쇼핑",
subcategory="생활용품",
db_path=db_path,
)
assert created["success"] is True
rule_id = created["rule"]["id"]
before = service.list_category_rules(active_only=False, db_path=db_path)
assert any(rule["id"] == rule_id for rule in before["rules"])
deleted = service.delete_category_rule(rule_id, db_path=db_path)
assert deleted == {"success": True, "deleted_rule_id": rule_id}
after_all = service.list_category_rules(active_only=False, db_path=db_path)
after_active = service.list_category_rules(active_only=True, db_path=db_path)
assert all(rule["id"] != rule_id for rule in after_all["rules"])
assert all(rule["id"] != rule_id for rule in after_active["rules"])
missing = service.delete_category_rule(rule_id, db_path=db_path)
assert missing["success"] is False
assert missing["error_code"] == "not_found"