def test_from_primitive(self): """ Check converting PDU to primitive """ orig = A_ASSOCIATE_AC() orig.Decode(a_associate_ac) primitive = orig.ToParams() new = A_ASSOCIATE_AC() new.FromParams(primitive) self.assertEqual(new, orig)
def test_update_data(self): """ Check that updating the PDU data works correctly """ original = A_ASSOCIATE_AC() original.Decode(a_associate_ac) original.user_information.user_data = [ original.user_information.user_data[1] ] original.get_length() primitive = original.ToParams() new = A_ASSOCIATE_AC() new.FromParams(primitive) self.assertEqual(original, new)
def test_to_primitive(self): """ Check converting PDU to primitive """ pdu = A_ASSOCIATE_AC() pdu.Decode(a_associate_ac) primitive = pdu.ToParams() self.assertEqual(primitive.application_context_name, UID('1.2.840.10008.3.1.1.1')) self.assertEqual(primitive.calling_ae_title, b'ECHOSCU ') self.assertEqual(primitive.called_ae_title, b'ANY-SCP ') # Test User Information for item in primitive.user_information: # Maximum PDU Length (required) if isinstance(item, MaximumLengthNegotiation): self.assertEqual(item.maximum_length_received, 16384) self.assertTrue(isinstance(item.maximum_length_received, int)) # Implementation Class UID (required) elif isinstance(item, ImplementationClassUIDNotification): self.assertEqual(item.implementation_class_uid, UID('1.2.276.0.7230010.3.0.3.6.0')) self.assertTrue(isinstance(item.implementation_class_uid, UID)) # Implementation Version Name (optional) elif isinstance(item, ImplementationVersionNameNotification): self.assertEqual(item.implementation_version_name, b'OFFIS_DCMTK_360') self.assertTrue( isinstance(item.implementation_version_name, bytes)) # Test Presentation Contexts for context in primitive.presentation_context_definition_list: self.assertEqual(context.ID, 1) self.assertEqual(context.TransferSyntax[0], UID('1.2.840.10008.1.2')) self.assertTrue(isinstance(primitive.application_context_name, UID)) self.assertTrue(isinstance(primitive.calling_ae_title, bytes)) self.assertTrue(isinstance(primitive.called_ae_title, bytes)) self.assertTrue(isinstance(primitive.user_information, list)) self.assertEqual(primitive.result, 0) self.assertEqual( len(primitive.presentation_context_definition_results_list), 1) # Not used by A-ASSOCIATE-AC or fixed value self.assertEqual(primitive.mode, "normal") self.assertEqual(primitive.responding_ae_title, primitive.called_ae_title) self.assertEqual(primitive.result_source, None) self.assertEqual(primitive.diagnostic, None) self.assertEqual(primitive.calling_presentation_address, None) self.assertEqual(primitive.called_presentation_address, None) self.assertEqual(primitive.responding_presentation_address, primitive.called_presentation_address) self.assertEqual(primitive.presentation_context_definition_list, []) self.assertEqual(primitive.presentation_requirements, "Presentation Kernel") self.assertEqual(primitive.session_requirements, "")