def test_message_to_primitive_c_move_with_duplicate_command_fields(self): msg = C_MOVE_RSP() for data in [c_move_rsp_cmd_with_dup, c_move_rsp_ds]: p_data = P_DATA() p_data.presentation_data_value_list.append([0, data]) msg.decode_msg(p_data) primitive = msg.message_to_primitive() assert isinstance(primitive, C_MOVE) assert isinstance(primitive.Identifier, BytesIO) assert primitive.AffectedSOPClassUID == UID( "1.2.840.10008.5.1.4.1.1.2") assert primitive.Status == 65280 assert primitive.MessageIDBeingRespondedTo == 5 # Fields with VM > 1 that can only appear once assert primitive.NumberOfRemainingSuboperations == 3 assert primitive.NumberOfCompletedSuboperations == 1 assert primitive.NumberOfFailedSuboperations == 2 assert primitive.NumberOfWarningSuboperations == 4 # Fields with VM > 1 that are allowed to appear multiple times assert primitive.OffendingElement == [(0x0, 0x1), (0x0, 0x2)] ds = decode(primitive.Identifier, True, True) assert ds.QueryRetrieveLevel == "PATIENT" assert ds.PatientID == "*"
def test_conversion_rsp(self): """ Check conversion to a -RSP PDU produces the correct output """ primitive = C_MOVE() primitive.MessageIDBeingRespondedTo = 5 primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2' primitive.Status = 0xFF00 primitive.NumberOfRemainingSuboperations = 3 primitive.NumberOfCompletedSuboperations = 1 primitive.NumberOfFailedSuboperations = 2 primitive.NumberOfWarningSuboperations = 4 ref_identifier = Dataset() ref_identifier.QueryRetrieveLevel = "PATIENT" ref_identifier.PatientID = "*" primitive.Identifier = BytesIO(encode(ref_identifier, True, True)) dimse_msg = C_MOVE_RSP() dimse_msg.primitive_to_message(primitive) pdvs = [] for fragment in dimse_msg.encode_msg(1, 16382): pdvs.append(fragment) cs_pdv = pdvs[0].presentation_data_value_list[0][1] ds_pdv = pdvs[1].presentation_data_value_list[0][1] assert cs_pdv == c_move_rsp_cmd assert ds_pdv == c_move_rsp_ds
def test_callback_receive_c_move(self): """Check callback for receiving DIMSE C-MOVE messages.""" # C-MOVE-RQ msg = C_MOVE_RQ() self.dimse.debug_receive_c_move_rq(msg) # C-MOVE-RSP primitive = C_MOVE() primitive.MessageIDBeingRespondedTo = 7 primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2' primitive.AffectedSOPInstanceUID = '1.2.392.200036.9116.2.6.1.48.' \ '1215709044.1459316254.522441' primitive.MoveOriginatorApplicationEntityTitle = 'UNITTEST_SCP' primitive.MoveOriginatorMessageID = 3 primitive.Identifier = BytesIO() primitive.NumberOfCompletedSuboperations = 1 primitive.NumberOfWarningSuboperations = 3 primitive.NumberOfFailedSuboperations = 4 # No dataset, remaining subops primitive.Status = 0x0000 # Must be for pending msg = C_MOVE_RSP() msg.primitive_to_message(primitive) self.dimse.debug_receive_c_move_rsp(msg) # Dataset ref_ds = Dataset() ref_ds.PatientID = 'Test1101' ref_ds.PatientName = "Tube HeNe" primitive.Identifier = BytesIO(encode(ref_ds, True, True)) primitive.NumberOfRemainingSuboperations = 2 msg = C_GET_RSP() msg.primitive_to_message(primitive) # Dataset self.dimse.debug_receive_c_move_rsp(msg) # C-CANCEL-MOVE-RQ self.dimse.debug_receive_c_cancel_rq(msg)
def test_message_to_primitive_c_move(self): """Test converting C_MOVE_RQ to C_MOVE primitive.""" msg = C_MOVE_RQ() for data in [c_move_rq_cmd, c_move_rq_ds]: p_data = P_DATA() p_data.presentation_data_value_list.append([0, data]) msg.decode_msg(p_data) primitive = msg.message_to_primitive() assert isinstance(primitive, C_MOVE) assert isinstance(primitive.Identifier, BytesIO) assert primitive.AffectedSOPClassUID == UID( "1.2.840.10008.5.1.4.1.1.2") assert primitive.Priority == 2 assert primitive.MoveDestination == "MOVE_SCP" assert primitive.MessageID == 7 ds = decode(primitive.Identifier, True, True) assert ds.QueryRetrieveLevel == "PATIENT" assert ds.PatientID == "*" msg = C_MOVE_RSP() for data in [c_move_rsp_cmd, c_move_rsp_ds]: p_data = P_DATA() p_data.presentation_data_value_list.append([0, data]) msg.decode_msg(p_data) primitive = msg.message_to_primitive() assert isinstance(primitive, C_MOVE) assert isinstance(primitive.Identifier, BytesIO) assert primitive.AffectedSOPClassUID == UID( "1.2.840.10008.5.1.4.1.1.2") assert primitive.Status == 65280 assert primitive.MessageIDBeingRespondedTo == 5 assert primitive.NumberOfRemainingSuboperations == 3 assert primitive.NumberOfCompletedSuboperations == 1 assert primitive.NumberOfFailedSuboperations == 2 assert primitive.NumberOfWarningSuboperations == 4 ds = decode(primitive.Identifier, True, True) assert ds.QueryRetrieveLevel == "PATIENT" assert ds.PatientID == "*"