def test_conversion_rq(self): """ Check conversion to a -RQ PDU produces the correct output """ primitive = N_SET() primitive.MessageID = 7 primitive.RequestedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2' primitive.RequestedSOPInstanceUID = '1.2.392.200036.9116.2.6.1.48' ds = Dataset() ds.PatientID = 'Test1101' ds.PatientName = "Tube HeNe" primitive.ModificationList = BytesIO(encode(ds, True, True)) dimse_msg = N_SET_RQ() dimse_msg.primitive_to_message(primitive) pdvs = [] for fragment in dimse_msg.encode_msg(1, 16382): pdvs.append(fragment) assert len(pdvs) == 2 cs_pdv = pdvs[0].presentation_data_value_list[0][1] ds_pdv = pdvs[1].presentation_data_value_list[0][1] assert cs_pdv == n_set_rq_cmd assert ds_pdv == n_set_rq_ds
def test_callback_receive_n_set(self): """Check callback for receiving DIMSE N-SET messages.""" # N-SET-RQ primitive = N_SET() primitive.MessageID = 1 primitive.RequestedSOPClassUID = '1.1.1' primitive.RequestedSOPInstanceUID = '1.1.1.1' primitive.ModificationList = BytesIO(n_set_rq_ds) msg = N_SET_RQ() msg.primitive_to_message(primitive) msg.context_id = 1 self.dimse.debug_receive_n_set_rq(msg) # N-SET-RSP primitive = N_SET() primitive.MessageIDBeingRespondedTo = 1 primitive.Status = 0x0000 msg = N_SET_RSP() msg.primitive_to_message(primitive) msg.context_id = 1 self.dimse.debug_receive_n_set_rsp(msg) # User defined primitive.AffectedSOPClassUID = '1.1.1' primitive.AffectedSOPInstanceUID = '1.1.1.1' primitive.ModificationList = BytesIO(n_set_rsp_ds) msg = N_GET_RSP() msg.primitive_to_message(primitive) msg.context_id = 1 self.dimse.debug_receive_n_set_rsp(msg)