fix: 修复 PDD 页面误判与失败回执 (#35)

This commit is contained in:
chengma
2026-08-07 17:58:30 +08:00
parent 51c2292be1
commit c59b4b0d59
11 changed files with 267 additions and 11 deletions
+37
View File
@@ -181,6 +181,43 @@ class HttpAdminGatewayTest(unittest.TestCase):
self.assertTrue(opener.request.full_url.endswith("/COL-001/failure"))
def test_submit_failure_accepts_legacy_admin_receipt_without_result_id(self):
gateway = HttpAdminGateway(
opener=RecordingOpener(
FakeResponse(
200,
{
"accepted": True,
"task_status": "assigned",
"accepted_at": "2026-08-07T08:00:01Z",
},
)
),
client_id="CLIENT-001",
)
receipt = gateway.submit_failure(
"COL-001",
"COL-001:ATTEMPT-001:failure-v1",
{"status": "retry_wait"},
)
self.assertTrue(receipt.accepted)
self.assertTrue(receipt.result_id.startswith("legacy-failure-"))
def test_malformed_2xx_submission_is_retryable_and_not_called_rejected(self):
gateway = HttpAdminGateway(
opener=RecordingOpener(FakeResponse(200, {"accepted": True})),
client_id="CLIENT-001",
)
with self.assertRaises(AdminGatewayError) as raised:
gateway.submit_result("COL-001", "key-1", {})
self.assertEqual(raised.exception.code, "ADMIN_INVALID_RESPONSE")
self.assertTrue(raised.exception.retryable)
self.assertIn("可能已接收", str(raised.exception))
def test_claim_maps_real_admin_payload_and_only_reports_collect(self):
opener = RecordingOpener(
FakeResponse(