test(store): 835 batch publishes remittance_written + activity_recorded
This commit is contained in:
@@ -123,6 +123,52 @@ async def test_add_837_publishes_claim_written_and_activity_recorded_events():
|
|||||||
assert "claimId" in ev
|
assert "claimId" in ev
|
||||||
|
|
||||||
|
|
||||||
|
def test_add_835_publishes_remittance_written_and_activity_recorded_events():
|
||||||
|
"""835 batches publish remittance_written events (one per remit) and
|
||||||
|
activity_recorded events (one per activity row)."""
|
||||||
|
import asyncio
|
||||||
|
from cyclone.pubsub import EventBus
|
||||||
|
from cyclone.store import BatchRecord835
|
||||||
|
|
||||||
|
# Reuse the 835 result helper from test_store_reconcile.py.
|
||||||
|
from test_store_reconcile import _make_835_result, _make_remit_with_cas
|
||||||
|
|
||||||
|
bus = EventBus()
|
||||||
|
remit_q = bus.subscribe(["remittance_written"])
|
||||||
|
activity_q = bus.subscribe(["activity_recorded"])
|
||||||
|
|
||||||
|
cp = _make_remit_with_cas(remit_id="CLP-PUB", pcn="PCN-PUB")
|
||||||
|
rec = BatchRecord835(
|
||||||
|
id="b-835-1", kind="835", input_filename="test835.txt",
|
||||||
|
parsed_at=datetime(2026, 6, 19, 12, 0, tzinfo=timezone.utc),
|
||||||
|
result=_make_835_result([cp]),
|
||||||
|
)
|
||||||
|
CycloneStore().add(rec, event_bus=bus)
|
||||||
|
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
try:
|
||||||
|
remits = []
|
||||||
|
for _ in range(1):
|
||||||
|
remits.append(loop.run_until_complete(
|
||||||
|
asyncio.wait_for(remit_q.__anext__(), timeout=0.5)
|
||||||
|
))
|
||||||
|
activities = []
|
||||||
|
for _ in range(1):
|
||||||
|
activities.append(loop.run_until_complete(
|
||||||
|
asyncio.wait_for(activity_q.__anext__(), timeout=0.5)
|
||||||
|
))
|
||||||
|
finally:
|
||||||
|
loop.close()
|
||||||
|
|
||||||
|
for ev in remits:
|
||||||
|
assert ev["_kind"] == "remittance_written"
|
||||||
|
assert ev["id"] == "PCN-PUB"
|
||||||
|
for ev in activities:
|
||||||
|
assert ev["_kind"] == "activity_recorded"
|
||||||
|
assert ev["kind"] == "remit_received"
|
||||||
|
assert ev["remittanceId"] == "PCN-PUB"
|
||||||
|
|
||||||
|
|
||||||
def test_add_837_persists_batch_and_claims():
|
def test_add_837_persists_batch_and_claims():
|
||||||
s = CycloneStore()
|
s = CycloneStore()
|
||||||
rec = _make_batch_record()
|
rec = _make_batch_record()
|
||||||
|
|||||||
Reference in New Issue
Block a user