@@ -495,6 +495,64 @@ async def test_forward_dr(worker_factory, http_server):
495495 assert req .body_json ["status" ]["id" ] == "m-21"
496496
497497
498+ async def test_forward_dr_delivered (worker_factory , http_server ):
499+ """
500+ A 'delivered' delivery report event referencing an outbound message we know
501+ about is forwarded over HTTP.
502+ """
503+ outbound = mkmsg ("hello" , from_addr = "+1234" )
504+ ev = mkev (
505+ "m-21" ,
506+ EventType .DELIVERY_REPORT ,
507+ delivery_status = DeliveryStatus .DELIVERED ,
508+ sent_message_id = outbound .message_id ,
509+ )
510+
511+ config = mk_config (http_server )
512+
513+ async with worker_factory .with_cleanup (TurnChannelsApi , config ) as tca_worker :
514+ await tca_worker .setup ()
515+ await tca_worker .message_cache .store_outbound (outbound )
516+ with fail_after (2 ):
517+ async with handle_event (tca_worker , ev ):
518+ req = await http_server .receive_req ()
519+ await http_server .send_rsp (RspInfo ())
520+
521+ assert req .path == "statuses"
522+ assert req .headers ["Content-Type" ] == "application/json"
523+ assert req .body_json ["status" ]["status" ] == "delivered"
524+ assert req .body_json ["status" ]["id" ] == "m-21"
525+
526+
527+ async def test_forward_dr_failed (worker_factory , http_server ):
528+ """
529+ A 'failed'delivery report event referencing an outbound message we know
530+ about is forwarded over HTTP.
531+ """
532+ outbound = mkmsg ("hello" , from_addr = "+1234" )
533+ ev = mkev (
534+ "m-21" ,
535+ EventType .DELIVERY_REPORT ,
536+ delivery_status = DeliveryStatus .FAILED ,
537+ sent_message_id = outbound .message_id ,
538+ )
539+
540+ config = mk_config (http_server )
541+
542+ async with worker_factory .with_cleanup (TurnChannelsApi , config ) as tca_worker :
543+ await tca_worker .setup ()
544+ await tca_worker .message_cache .store_outbound (outbound )
545+ with fail_after (2 ):
546+ async with handle_event (tca_worker , ev ):
547+ req = await http_server .receive_req ()
548+ await http_server .send_rsp (RspInfo ())
549+
550+ assert req .path == "statuses"
551+ assert req .headers ["Content-Type" ] == "application/json"
552+ assert req .body_json ["status" ]["status" ] == "failed"
553+ assert req .body_json ["status" ]["id" ] == "m-21"
554+
555+
498556async def test_send_outbound (worker_factory , http_server , tca_ro ):
499557 """
500558 An outbound message received over HTTP is forwarded over AMQP.
0 commit comments