fix(projekt-matching): normalize unknown statuses, alert failure cannot block trash
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,6 +90,34 @@ def test_lock_prevents_second_run(tmp_path):
|
||||
ingest.release_lock(lock)
|
||||
|
||||
|
||||
def test_unknown_dispatch_status_normalized_to_failed(tmp_path):
|
||||
mails = {"1": mail("Mail", PROJECT_HTML)}
|
||||
summary, box, sent = run(tmp_path, mails,
|
||||
dispatch_result={"weird": True})
|
||||
assert summary["failed"] == 1
|
||||
box.move_to_trash.assert_called_once()
|
||||
|
||||
|
||||
def test_alert_send_failure_still_trashes(tmp_path):
|
||||
mails = {"1": mail("Mail", PROJECT_HTML)}
|
||||
box = mock.Mock()
|
||||
box.unchecked_uids.return_value = list(mails)
|
||||
box.fetch.side_effect = lambda uid: mails[uid]
|
||||
espo = mock.Mock()
|
||||
espo.find_opportunity_by_link.return_value = None
|
||||
def boom_send(*a):
|
||||
raise OSError("smtp down")
|
||||
with mock.patch("projektmatch.ingest.mailparse.bodies",
|
||||
side_effect=lambda m: (m["html"], "")), \
|
||||
mock.patch("projektmatch.ingest.mailer.send_mail", boom_send):
|
||||
summary = ingest.run_ingest(
|
||||
cfg(tmp_path), mailbox=box, espo=espo,
|
||||
resolve=lambda url: "https://www.freelancermap.de/projekt/eins",
|
||||
dispatch=lambda item: {"status": "failed", "error": "x"})
|
||||
assert summary["alertFailed"] == 1
|
||||
box.move_to_trash.assert_called_once_with("1")
|
||||
|
||||
|
||||
def test_parse_run_result_finds_status_json():
|
||||
inner = json.dumps({"status": "created", "mustMatch": 90})
|
||||
payload = {"outputs": [{"outputs": [{"results": {"text": {
|
||||
|
||||
Reference in New Issue
Block a user