def test_from_primitive(self): """Check converting primitive to PDU.""" orig_pdu = A_ASSOCIATE_RQ() orig_pdu.decode(a_associate_rq) primitive = orig_pdu.to_primitive() new_pdu = A_ASSOCIATE_RQ() new_pdu.from_primitive(primitive) assert new_pdu == orig_pdu assert new_pdu.encode() == a_associate_rq
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) pc = PresentationContext() pc.context_id = 1 pc.abstract_syntax = '1.2.840.10008.1.1' pc.transfer_syntax = ['1.2.840.10008.1.2'] assoc.presentation_context_definition_list = [pc] pdu = A_ASSOCIATE_RQ() pdu.from_primitive(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" assert data == ref