def test_aet_short_false(self): """Test using long AE titles.""" primitive = C_STORE() primitive.MoveOriginatorApplicationEntityTitle = "A" aet = primitive.MoveOriginatorApplicationEntityTitle assert "A" == aet
def test_is_valid_resposne(self): """Test C_STORE.is_valid_response.""" primitive = C_STORE() assert not primitive.is_valid_response primitive.MessageIDBeingRespondedTo = 1 assert not primitive.is_valid_response primitive.Status = 0x0000 assert primitive.is_valid_response
def test_aet_short_false(self): """Test using long AE titles.""" primitive = C_STORE() _config.USE_SHORT_DIMSE_AET = False primitive.MoveOriginatorApplicationEntityTitle = b'A' aet = primitive.MoveOriginatorApplicationEntityTitle assert b'A ' == aet
def test_uid_exceptions_true(self): """Test ValueError raised with ENFORCE_UID_CONFORMANCE = True.""" primitive = C_STORE() _config.ENFORCE_UID_CONFORMANCE = True with pytest.raises(ValueError): primitive.AffectedSOPClassUID = 'abc' with pytest.raises(ValueError): primitive.AffectedSOPInstanceUID = 'abc'
def test_conversion_rq(self): """ Check conversion to a -RQ PDU produces the correct output """ primitive = C_STORE() primitive.MessageID = 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.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = 'UNITTEST_SCP' primitive.MoveOriginatorMessageID = 3 ref_ds = Dataset() ref_ds.PatientID = 'Test1101' ref_ds.PatientName = "Tube HeNe" primitive.DataSet = BytesIO(encode(ref_ds, True, True)) dimse_msg = C_STORE_RQ() 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_store_rq_cmd_b assert ds_pdv == c_store_rq_ds_b
def test_aet_deprecation(self): """Test deprecation warning for Move Original AET from bytes.""" primitive = C_STORE() msg = ( "The use of bytes with 'Move Originator AE Title' is deprecated, " "use an ASCII str instead") with pytest.warns(DeprecationWarning, match=msg): primitive.MoveOriginatorApplicationEntityTitle = b'TEST' assert primitive.MoveOriginatorApplicationEntityTitle == 'TEST'
def setup(self): primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = '1.1.1' primitive.AffectedSOPInstanceUID = '1.2.1' primitive.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = b'UNITTEST' primitive.MoveOriginatorMessageID = 3 primitive.DataSet = BytesIO(encode(DATASET, True, True)) self.msg = C_STORE_RQ() self.msg.primitive_to_message(primitive)
def message_to_primitive(self): """Convert the ``DIMSEMessage`` class to a DIMSE primitive. Returns ------- DIMSEPrimitive sub-class One of the DIMSE message primitives from :ref:`pynetdicom.dimse_primitives<api_dimse_primitives>` generated from the current ``DIMSEMessage`` sub-class object. """ # pylint: disable=too-many-branches cls_type_name = self.__class__.__name__ if 'C_ECHO' in cls_type_name: primitive = C_ECHO() elif 'C_STORE' in cls_type_name: primitive = C_STORE() elif 'C_FIND' in cls_type_name: primitive = C_FIND() elif 'C_GET' in cls_type_name: primitive = C_GET() elif 'C_MOVE' in cls_type_name: primitive = C_MOVE() elif 'C_CANCEL' in cls_type_name: primitive = C_CANCEL() elif 'N_EVENT' in cls_type_name: primitive = N_EVENT_REPORT() elif 'N_GET' in cls_type_name: primitive = N_GET() elif 'N_SET' in cls_type_name: primitive = N_SET() elif 'N_ACTION' in cls_type_name: primitive = N_ACTION() elif 'N_CREATE' in cls_type_name: primitive = N_CREATE() elif 'N_DELETE' in cls_type_name: primitive = N_DELETE() # Command Set # For each parameter in the primitive, set the appropriate value # from the Message's Command Set elements for elem in self.command_set: if hasattr(primitive, elem.keyword): setattr( primitive, elem.keyword, self.command_set.__getattr__(elem.keyword) ) # Datasets # Set the primitive's DataSet/Identifier/etc attribute try: dataset_keyword = _DATASET_KEYWORDS[cls_type_name] setattr(primitive, dataset_keyword, self.data_set) except KeyError: pass # Set the presentation context ID the message was set under primitive._context_id = self.context_id return primitive
def setup(self): """Run prior to each test""" primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = '1.1.1' primitive.AffectedSOPInstanceUID = '1.2.1' primitive.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = b'UNITTEST' primitive.MoveOriginatorMessageID = 3 primitive.DataSet = BytesIO(encode(DATASET, True, True)) msg = C_STORE_RQ() msg.primitive_to_message(primitive) self.fragments = msg.encode_msg(1, 16382)
def test_validate_status_ds(self): """Test that validate_status works correctly with dataset""" sop = StorageServiceClass(None) rsp = C_STORE() status = Dataset() status.Status = 0x0001 rsp = sop.validate_status(status, rsp) assert rsp.Status == 0x0001
def test_validate_status_ds_none(self): """Test correct status returned if ds has no Status element.""" sop = StorageServiceClass(None) rsp = C_STORE() status = Dataset() status.ErrorComment = 'Test comment' rsp = sop.validate_status(status, rsp) assert rsp.Status == 0xC001
def test_validate_status_ds_unknown(self): """Test a status ds with an unknown element.""" sop = StorageServiceClass(None) rsp = C_STORE() status = Dataset() status.Status = 0x0000 status.PatientName = 'Test comment' rsp = sop.validate_status(status, rsp)
def test_encode(self): """Test encoding of a DIMSE message.""" primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = "1.1.1" primitive.AffectedSOPInstanceUID = "1.2.1" primitive.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = "UNITTEST" primitive.MoveOriginatorMessageID = 3 # Test encode without dataset dimse_msg = C_STORE_RQ() dimse_msg.primitive_to_message(primitive) p_data_list = [] for pdata in dimse_msg.encode_msg(12, 16): p_data_list.append(pdata) assert p_data_list[0].presentation_data_value_list[0][1][ 0:1] == b"\x01" assert p_data_list[-1].presentation_data_value_list[0][1][ 0:1] == b"\x03" assert dimse_msg.context_id == 12 # Test encode with dataset ds = Dataset() ds.PatientID = "Test1101" ds.PatientName = "Tube^HeNe" primitive.DataSet = BytesIO(encode(ds, True, True)) dimse_msg = C_STORE_RQ() dimse_msg.primitive_to_message(primitive) p_data_list = [] for pdata in dimse_msg.encode_msg(13, 10): p_data_list.append(pdata) assert p_data_list[0].presentation_data_value_list[0][1][ 0:1] == b"\x01" assert p_data_list[-1].presentation_data_value_list[0][1][ 0:1] == b"\x02" assert p_data_list[-2].presentation_data_value_list[0][1][ 0:1] == b"\x00" assert p_data_list[-10].presentation_data_value_list[0][1][ 0:1] == b"\x03" assert dimse_msg.context_id == 13 p_data_list = [] for pdata in dimse_msg.encode_msg(1, 31682): p_data_list.append(pdata) assert p_data_list[0].presentation_data_value_list[0][ 1] == c_store_rq_cmd assert p_data_list[1].presentation_data_value_list[0][1] == c_store_ds
def test_scp_failed_ds_decode(self): """Test failure to decode the dataset""" # Hard to test directly as decode errors won't show up until the # dataset is actually used self.scp = DummyStorageSCP() self.scp.status = 0x0000 self.scp.start() ae = AE() ae.add_requested_context(HangingProtocolStorage, ExplicitVRLittleEndian) assoc = ae.associate('localhost', 11112) assert assoc.is_established req = C_STORE() req.MessageID = 1 req.AffectedSOPClassUID = DATASET.SOPClassUID req.AffectedSOPInstanceUID = DATASET.SOPInstanceUID req.Priorty = 0x0002 req.DataSet = BytesIO(b'\x08\x00\x01\x00\x04\x00\x00\x00\x00\x08\x00\x49') # Send C-STORE request to DIMSE and get response assoc.dimse.send_msg(req, 1) rsp, _ = assoc.dimse.receive_msg(True) assert rsp.Status == 0xC100 assert rsp.ErrorComment == 'Unable to decode the dataset' assoc.release() self.scp.stop()
def test_validate_status_ds_multi(self): """Test that validate_status works correctly with dataset multi""" sop = StorageServiceClass(None) rsp = C_STORE() status = Dataset() status.Status = 0x0002 status.ErrorComment = 'test' rsp = sop.validate_status(status, rsp) assert rsp.Status == 0x0002 assert rsp.ErrorComment == 'test'
def test_decode(self): """Test decoding of a DIMSE message.""" primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = "1.1.1" primitive.AffectedSOPInstanceUID = "1.2.1" primitive.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = "UNITTEST" primitive.MoveOriginatorMessageID = 3 ds = Dataset() ds.PatientID = "Test1101" ds.PatientName = "Tube^HeNe" primitive.DataSet = BytesIO(encode(ds, True, True)) dimse_msg = C_STORE_RQ() dimse_msg.primitive_to_message(primitive) # CMD: (1x4, 3x1), DS: (0x1, 2x1) p_data = dimse_msg.encode_msg(12, 24) # Command set decoding dimse_msg.decode_msg(next(p_data)) # MCHB 1 dimse_msg.decode_msg(next(p_data)) # MCHB 1 dimse_msg.decode_msg(next(p_data)) # MCHB 1 dimse_msg.decode_msg(next(p_data)) # MCHB 1 dimse_msg.decode_msg(next(p_data)) # MCHB 3 - end of command set assert dimse_msg.__class__ == C_STORE_RQ # Test decoded command set cs = dimse_msg.command_set assert cs.CommandGroupLength == 94 assert cs.AffectedSOPClassUID == UID("1.1.1") assert cs.AffectedSOPInstanceUID == UID("1.2.1") assert cs.Priority == 2 assert cs.CommandDataSetType == 1 assert cs.CommandField == 1 assert cs.MoveOriginatorApplicationEntityTitle == "UNITTEST" assert cs.MoveOriginatorMessageID == 3 # Test decoded dataset dimse_msg.decode_msg(next(p_data)) # MCHB 1 # MCHB 0 dimse_msg.decode_msg(next(p_data)) # MCHB 1 # MCHB 2 assert dimse_msg.data_set.getvalue() == c_store_ds[1:] # Test returns false msg = C_STORE_RSP() assert not msg.decode_msg(c_store_rsp_cmd)
def test_scp_failed_ds_decode(self): """Test failure to decode the dataset""" # Hard to test directly as decode errors won't show up until the # dataset is actually used def handle(event): try: for elem in event.dataset.iterall(): pass except: status = Dataset() status.Status = 0xC210 status.ErrorComment = "Unable to decode the dataset" return status return 0x0000 handlers = [(evt.EVT_C_STORE, handle)] self.ae = ae = AE() ae.add_supported_context(HangingProtocolStorage) ae.add_requested_context(HangingProtocolStorage, ExplicitVRLittleEndian) scp = ae.start_server(("localhost", 11112), block=False, evt_handlers=handlers) assoc = ae.associate("localhost", 11112) assert assoc.is_established req = C_STORE() req.MessageID = 1 req.AffectedSOPClassUID = DATASET.SOPClassUID req.AffectedSOPInstanceUID = DATASET.SOPInstanceUID req.Priority = 0x0002 # Bad VR? AA req.DataSet = BytesIO( b"\x08\x00\x01\x00\x40\x40\x00\x00\x00\x00\x00\x08\x00\x49") # Send C-STORE request to DIMSE and get response # Need to manually hit the checkpoint assoc._reactor_checkpoint.clear() assoc.dimse.send_msg(req, 1) with pytest.warns(UserWarning): cx_id, rsp = assoc.dimse.get_msg(True) assoc._reactor_checkpoint.set() assert rsp.Status == 0xC210 assert rsp.ErrorComment == "Unable to decode the dataset" assoc.release() assert assoc.is_released scp.shutdown()
def test_cstore_rq(self): """Test creation of a DIMSE Message from a primitive works OK.""" # Testing that primitive_to_message doesn't affect the original class # definition req = C_STORE() req.MessageID = 12 req.AffectedSOPClassUID = self.ds.SOPClassUID req.AffectedSOPInstanceUID = self.ds.SOPInstanceUID req.Priority = 0x02 req.MoveOriginatorApplicationEntityTitle = None req.MoveOriginatorMessageID = None req.DataSet = BytesIO(encode(self.ds, True, True)) msg = C_STORE_RQ() msg.primitive_to_message(req) cs = msg.command_set assert cs.CommandGroupLength == 88 assert cs.AffectedSOPClassUID == "1.2.840.10008.5.1.4.1.1" assert cs.CommandField == 1 assert cs.MessageID == 12 assert cs.Priority == 2 assert cs.CommandDataSetType == 1 assert cs.AffectedSOPInstanceUID == "1.2.3.4" assert "MoveOriginatorApplicationEntityTitle" not in cs assert "MoveOriginatorMessageID" not in cs assert msg.data_set.getvalue() != b"" # Test new class instance is OK msg = C_STORE_RQ() cs = msg.command_set ds = msg.data_set assert cs.CommandGroupLength is None assert cs.AffectedSOPClassUID in ["", None] # pydicom upstream change assert cs.CommandField is None assert cs.MessageID is None assert cs.Priority is None assert cs.CommandDataSetType is None assert cs.AffectedSOPInstanceUID in ["", None] assert cs.MoveOriginatorApplicationEntityTitle is None assert cs.MoveOriginatorMessageID is None assert ds.getvalue() == b""
def test_is_valid_request(self): """Test C_STORE.is_valid_request""" primitive = C_STORE() assert not primitive.is_valid_request primitive.MessageID = 1 assert not primitive.is_valid_request primitive.AffectedSOPClassUID = '1.2' assert not primitive.is_valid_request primitive.Priority = 2 assert not primitive.is_valid_request primitive.AffectedSOPInstanceUID = '1.2.1' assert not primitive.is_valid_request primitive.DataSet = BytesIO() assert primitive.is_valid_request
def test_encode_zero(self): """Test encoding with a 0 max pdu length.""" primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = '1.1.1' primitive.AffectedSOPInstanceUID = '1.2.1' primitive.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = 'UNITTEST' primitive.MoveOriginatorMessageID = 3 # Test encode without dataset dimse_msg = C_STORE_RQ() dimse_msg.primitive_to_message(primitive) p_data_list = [] for pdata in dimse_msg.encode_msg(12, 0): p_data_list.append(pdata) assert p_data_list[0].presentation_data_value_list[0][1][ 0:1] == b'\x03' assert dimse_msg.context_id == 12 # Test encode with dataset ds = Dataset() ds.PatientID = 'Test1101' ds.PatientName = 'Tube^HeNe' primitive.DataSet = BytesIO(encode(ds, True, True)) dimse_msg = C_STORE_RQ() dimse_msg.primitive_to_message(primitive) p_data_list = [] for pdata in dimse_msg.encode_msg(13, 0): p_data_list.append(pdata) assert p_data_list[0].presentation_data_value_list[0][1][ 0:1] == b'\x03' assert p_data_list[0].presentation_data_value_list[0][ 1] == c_store_rq_cmd assert p_data_list[1].presentation_data_value_list[0][1][ 0:1] == b'\x02' assert p_data_list[1].presentation_data_value_list[0][1] == c_store_ds assert dimse_msg.context_id == 13
def test_status_enum(self): """Test failure to decode the dataset""" # Hard to test directly as decode errors won't show up until the # dataset is actually used Status.add('UNABLE_TO_DECODE', 0xC210) def handle(event): try: for elem in event.dataset.iterall(): pass except: status = Dataset() status.Status = Status.UNABLE_TO_DECODE status.ErrorComment = "Unable to decode the dataset" return status return Status.SUCCESS handlers = [(evt.EVT_C_STORE, handle)] self.ae = ae = AE() ae.add_supported_context(CTImageStorage) ae.add_requested_context(CTImageStorage, ExplicitVRLittleEndian) scp = ae.start_server(('', 11112), block=False, evt_handlers=handlers) assoc = ae.associate('localhost', 11112) assert assoc.is_established req = C_STORE() req.MessageID = 1 req.AffectedSOPClassUID = DATASET.SOPClassUID req.AffectedSOPInstanceUID = DATASET.SOPInstanceUID req.Priorty = 0x0002 req.DataSet = BytesIO( b'\x08\x00\x01\x00\x40\x40\x00\x00\x00\x00\x00\x08\x00\x49') # Send C-STORE request to DIMSE and get response assoc._reactor_checkpoint.clear() assoc.dimse.send_msg(req, 1) with pytest.warns(UserWarning): cx_id, rsp = assoc.dimse.get_msg(True) assoc._reactor_checkpoint.set() assert rsp.Status == 0xC210 assert rsp.ErrorComment == 'Unable to decode the dataset' assoc.release() assert assoc.is_released scp.shutdown()
def test_conversion_rsp(self): """ Check conversion to a -RSP PDU produces the correct output """ primitive = C_STORE() primitive.MessageIDBeingRespondedTo = 5 primitive.AffectedSOPClassUID = '1.2.4.10' primitive.AffectedSOPInstanceUID = '1.2.4.5.7.8' primitive.Status = 0x0000 dimse_msg = C_STORE_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] assert cs_pdv == c_store_rsp_cmd
def test_uid_exceptions_false(self): """Test ValueError raised with ENFORCE_UID_CONFORMANCE = False.""" primitive = C_STORE() _config.ENFORCE_UID_CONFORMANCE = False primitive.AffectedSOPClassUID = 'abc' assert primitive.AffectedSOPClassUID == 'abc' primitive.AffectedSOPInstanceUID = 'abc' assert primitive.AffectedSOPInstanceUID == 'abc' # Can't have more than 64 characters with pytest.raises(ValueError): primitive.AffectedSOPClassUID = 'abc' * 22 with pytest.raises(ValueError): primitive.AffectedSOPInstanceUID = 'abc' * 22
def test_primitive_to_message(self): """Test converting a DIMSE primitive to a DIMSE message.""" primitive = C_STORE() primitive.MessageID = 7 primitive.AffectedSOPClassUID = "1.1.1" primitive.AffectedSOPInstanceUID = "1.2.1" primitive.Priority = 0x02 msg = C_STORE_RQ() msg.primitive_to_message(primitive) # Test unused command set elements are deleted assert not "MoveOriginatorApplicationEntityTitle" in msg.command_set # Test raise error for unknown DIMSE message type msg.__class__.__name__ = "TestClass" with pytest.raises(ValueError): msg.primitive_to_message(primitive) # Reset name to avoid errors in other tests msg.__class__.__name__ = "C_STORE_RQ"
def test_aet_short_true(self): """Test using short AE titles.""" primitive = C_STORE() _config.USE_SHORT_DIMSE_AET = True primitive.MoveOriginatorApplicationEntityTitle = b'A' aet = primitive.MoveOriginatorApplicationEntityTitle assert b'A ' == aet primitive.MoveOriginatorApplicationEntityTitle = b'ABCDEFGHIJKLMNO' aet = primitive.MoveOriginatorApplicationEntityTitle assert b'ABCDEFGHIJKLMNO ' == aet primitive.MoveOriginatorApplicationEntityTitle = b'ABCDEFGHIJKLMNOP' aet = primitive.MoveOriginatorApplicationEntityTitle assert b'ABCDEFGHIJKLMNOP' == aet primitive.MoveOriginatorApplicationEntityTitle = b'ABCDEFGHIJKLMNOPQ' aet = primitive.MoveOriginatorApplicationEntityTitle assert b'ABCDEFGHIJKLMNOP' == aet
def test_aet_short_true(self, caplog, use_long_aet): """Test using short AE titles.""" primitive = C_STORE() primitive.MoveOriginatorApplicationEntityTitle = "A" aet = primitive.MoveOriginatorApplicationEntityTitle assert "A" == aet primitive.MoveOriginatorApplicationEntityTitle = "ABCDEFGHIJKLMNO" aet = primitive.MoveOriginatorApplicationEntityTitle assert "ABCDEFGHIJKLMNO" == aet primitive.MoveOriginatorApplicationEntityTitle = "ABCDEFGHIJKLMNOP" aet = primitive.MoveOriginatorApplicationEntityTitle assert "ABCDEFGHIJKLMNOP" == aet with caplog.at_level(logging.ERROR, logger="pynetdicom"): primitive.MoveOriginatorApplicationEntityTitle = "ABCDEFGHIJKLMNOPQ" assert primitive.MoveOriginatorApplicationEntityTitle is None assert ( "Invalid 'Move Originator AE Title' in C-STORE request" ) in caplog.text
def test_callback_receive_c_store(self): """Check callback for sending DIMSE C-STORE messages.""" # C-STORE-RQ primitive = C_STORE() primitive.MessageID = 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.Priority = 0x02 primitive.MoveOriginatorApplicationEntityTitle = 'UNITTEST_SCP' primitive.MoveOriginatorMessageID = 3 primitive.DataSet = BytesIO() # No dataset msg = C_STORE_RQ() msg.primitive_to_message(primitive) self.dimse.debug_receive_c_store_rq(msg) # Dataset ref_ds = Dataset() ref_ds.PatientID = 'Test1101' ref_ds.PatientName = "Tube HeNe" primitive.DataSet = BytesIO(encode(ref_ds, True, True)) msg = C_STORE_RQ() msg.primitive_to_message(primitive) # Dataset self.dimse.debug_receive_c_store_rq(msg) # C-STORE-RSP primitive = C_STORE() 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.DataSet = BytesIO() # Check statuses + no dataset for status in [0x0000, 0xb000, 0xb007, 0xb006, 0xa700, 0xa900, 0xc000]: primitive.Status = status msg = C_STORE_RSP() msg.primitive_to_message(primitive) self.dimse.debug_receive_c_store_rsp(msg) # Dataset ref_ds = Dataset() ref_ds.PatientID = 'Test1101' ref_ds.PatientName = "Tube HeNe" msg = C_STORE_RSP() msg.primitive_to_message(primitive) # Dataset msg.data_set = BytesIO(encode(ref_ds, True, True)) self.dimse.debug_receive_c_store_rsp(msg)
def test_callback_send_c_store(self): """Check callback for sending DIMSE C-STORE messages.""" # C-STORE-RQ primitive = C_STORE() primitive.MessageID = 1 primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.2' # CT primitive.AffectedSOPInstanceUID = '1.1.2' primitive.Priority = 0x02 primitive.DataSet = BytesIO() # CT + no dataset self.dimse.send_msg(primitive, 1) primitive.AffectedSOPClassUID = '1.1.1' # No UID type, no dataset # MR + dataset primitive.AffectedSOPClassUID = '1.2.840.10008.5.1.4.1.1.4' # MR bytestream = BytesIO() bytestream.write(c_store_ds) primitive.DataSet = bytestream self.dimse.send_msg(primitive, 1) # C-STORE-RSP primitive = C_STORE() primitive.MessageIDBeingRespondedTo = 1 primitive.Status = 0x0000 self.dimse.send_msg(primitive, 1)
"""Dummy Send method to test DIMSEServiceProvider.Send""" pass @staticmethod def receive_pdu(): """Dummy Receive method to test DIMSEServiceProvider.Receive""" pass @staticmethod def peek_next_pdu(): return 0x01 REFERENCE_MSG = [ (C_ECHO(), ('C_ECHO_RQ', 'C_ECHO_RSP')), (C_STORE(), ('C_STORE_RQ', 'C_STORE_RSP')), (C_FIND(), ('C_FIND_RQ', 'C_FIND_RSP')), (C_GET(), ('C_GET_RQ', 'C_GET_RSP')), (C_MOVE(), ('C_MOVE_RQ', 'C_MOVE_RSP')), (C_CANCEL(), (None, 'C_CANCEL_RQ')), (N_EVENT_REPORT(), ('N_EVENT_REPORT_RQ', 'N_EVENT_REPORT_RSP')), (N_GET(), ('N_GET_RQ', 'N_GET_RSP')), (N_SET(), ('N_SET_RQ', 'N_SET_RSP')), (N_ACTION(), ('N_ACTION_RQ', 'N_ACTION_RSP')), (N_CREATE(), ('N_CREATE_RQ', 'N_CREATE_RSP')), (N_DELETE(), ('N_DELETE_RQ', 'N_DELETE_RSP')), ] class TestDIMSEProvider(object): """Test DIMSE service provider operations."""
def test_validate_status_unknown(self): """Test return unknown status""" sop = StorageServiceClass(None) rsp = C_STORE() rsp = sop.validate_status(0xD011, rsp) assert rsp.Status == 0xD011