Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def test_to_primitive(self):
        """ Check converting PDU to primitive """
        pdu = A_ASSOCIATE_RQ()
        pdu.Decode(a_associate_rq)

        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, 16382)
                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.826.0.1.3680043.9.3811.0.9.0'))
                self.assertTrue(isinstance(item.implementation_class_uid, UID))

            # Implementation Version Name (optional)
            elif isinstance(item, ImplementationVersionNameNotification):
                self.assertEqual(item.implementation_version_name,
                                 b'PYNETDICOM_090')
                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.AbstractSyntax, UID('1.2.840.10008.1.1'))
            for syntax in context.TransferSyntax:
                self.assertEqual(syntax, 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.assertTrue(
            isinstance(primitive.presentation_context_definition_list, list))

        # Not used by A-ASSOCIATE-RQ or fixed value
        self.assertEqual(primitive.mode, "normal")
        self.assertEqual(primitive.responding_ae_title,
                         primitive.called_ae_title)
        self.assertEqual(primitive.result, None)
        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_results_list, [])
        self.assertEqual(primitive.presentation_requirements,
                         "Presentation Kernel")
        self.assertEqual(primitive.session_requirements, "")