+def test_send_rcv_subid_good():
+ """
+ test send and receive where subid is used for routing
+ """
+ pay = b"\x01\x00\x80"
+ test_mtype = 46656
+ test_subid = 777
+
+ # send a message
+ sbuf_send = rmr.rmr_alloc_msg(MRC_SEND, 3, pay, mtype=test_mtype, sub_id=test_subid)
+ pre_send_summary = rmr.message_summary(sbuf_send)
+ sbuf_send = rmr.rmr_send_msg(MRC_SEND, sbuf_send)
+ send_summary = rmr.message_summary(sbuf_send)
+
+ # receive it in other context
+ time.sleep(0.5)
+ sbuf_rcv = rmr.rmr_alloc_msg(MRC_RCV, 3)
+ sbuf_rcv = rmr.rmr_torcv_msg(MRC_RCV, sbuf_rcv, 2000)
+ rcv_summary = rmr.message_summary(sbuf_rcv)
+
+ # asserts
+ assert send_summary["message state"] == rcv_summary["message state"] == 0
+ assert send_summary["message status"] == rcv_summary["message status"] == "RMR_OK"
+ assert pre_send_summary["payload"] == rcv_summary["payload"] == pay
+ assert pre_send_summary["message type"] == rcv_summary["message type"] == test_mtype
+ assert pre_send_summary["subscription id"] == rcv_summary["subscription id"] == test_subid
+
+
+def test_send_rcv_subid_bad_subid():
+ """
+ test send and receive where subid is used for routing but nobody recieves this subid
+ """
+ sbuf_send = rmr.rmr_alloc_msg(MRC_SEND, 3, b"\x01\x00\x80", mtype=46656, sub_id=778)
+ sbuf_send = rmr.rmr_send_msg(MRC_SEND, sbuf_send)
+ assert rmr.message_summary(sbuf_send)["message state"] == 2
+ assert rmr.message_summary(sbuf_send)["message status"] == "RMR_ERR_NOENDPT"
+
+
+def test_send_rcv_subid_bad_mtype():
+ """
+ test send and receive where subid is used for routing but nobody recieves this mtype
+ """
+ sbuf_send = rmr.rmr_alloc_msg(MRC_SEND, 3, b"\x01\x00\x80", mtype=46657, sub_id=777)
+ sbuf_send = rmr.rmr_send_msg(MRC_SEND, sbuf_send)
+ assert rmr.message_summary(sbuf_send)["message state"] == 2
+ assert rmr.message_summary(sbuf_send)["message status"] == "RMR_ERR_NOENDPT"
+
+