def test_from_primitive(self): """ Check converting PDU to primitive """ orig_pdu = A_ASSOCIATE_RQ() orig_pdu.Decode(a_associate_rq) primitive = orig_pdu.ToParams() new_pdu = A_ASSOCIATE_RQ() new_pdu.FromParams(primitive) self.assertEqual(new_pdu, orig_pdu)
def test_update_data(self): """ Check that updating the PDU data works correctly """ orig_pdu = A_ASSOCIATE_RQ() orig_pdu.Decode(a_associate_rq) orig_pdu.user_information.user_data = [ orig_pdu.user_information.user_data[1] ] orig_pdu.get_length() primitive = orig_pdu.ToParams() new_pdu = A_ASSOCIATE_RQ() new_pdu.FromParams(primitive) self.assertEqual(new_pdu, orig_pdu)
def test_conversion(self): """ Check conversion to a PDU produces the correct output """ assoc = A_ASSOCIATE() assoc.application_context_name = "1.2.840.10008.3.1.1.1" assoc.calling_ae_title = 'ECHOSCU' assoc.called_ae_title = 'ANY-SCP' assoc.maximum_length_received = 16382 assoc.implementation_class_uid = '1.2.826.0.1.3680043.9.3811.0.9.0' imp_ver_name = ImplementationVersionNameNotification() imp_ver_name.implementation_version_name = 'PYNETDICOM_090' assoc.user_information.append(imp_ver_name) assoc.presentation_context_definition_list = \ [PresentationContext(1, '1.2.840.10008.1.1', ['1.2.840.10008.1.2'])] pdu = A_ASSOCIATE_RQ() pdu.FromParams(assoc) data = pdu.encode() ref = b"\x01\x00\x00\x00\x00\xd1\x00\x01\x00\x00\x41\x4e\x59\x2d\x53\x43" \ b"\x50\x20\x20\x20\x20\x20\x20\x20\x20\x20\x45\x43\x48\x4f\x53\x43" \ b"\x55\x20\x20\x20\x20\x20\x20\x20\x20\x20\x00\x00\x00\x00\x00\x00" \ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x15\x31\x2e" \ b"\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x33\x2e\x31\x2e" \ b"\x31\x2e\x31\x20\x00\x00\x2e\x01\x00\x00\x00\x30\x00\x00\x11\x31" \ b"\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x31\x2e\x31" \ b"\x40\x00\x00\x11\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30" \ b"\x38\x2e\x31\x2e\x32\x50\x00\x00\x3e\x51\x00\x00\x04\x00\x00\x3f" \ b"\xfe\x52\x00\x00\x20\x31\x2e\x32\x2e\x38\x32\x36\x2e\x30\x2e\x31" \ b"\x2e\x33\x36\x38\x30\x30\x34\x33\x2e\x39\x2e\x33\x38\x31\x31\x2e" \ b"\x30\x2e\x39\x2e\x30\x55\x00\x00\x0e\x50\x59\x4e\x45\x54\x44\x49" \ b"\x43\x4f\x4d\x5f\x30\x39\x30" self.assertTrue(data == ref)