Ejemplo n.º 1
0
    def test_assignment(self):
        """ Check assignment works correctly """
        assoc = A_RELEASE()
        self.assertEqual(assoc.reason, "normal")

        assoc.result = "affirmative"
        self.assertEqual(assoc.result, "affirmative")
Ejemplo n.º 2
0
    def test_exceptions(self):
        """ Check incorrect types/values for properties raise exceptions """
        assoc = A_RELEASE()

        with self.assertRaises(AttributeError):
            assoc.reason = "something"

        with pytest.raises(ValueError):
            assoc.result = "accepted"
Ejemplo n.º 3
0
    def test__primitive_to_event(self):
        """Test that parameter returns expected results"""
        dul = DummyDUL()
        p2e = dul._primitive_to_event

        primitive = A_ASSOCIATE()
        primitive.result = None
        self.assertEqual(p2e(primitive), 'Evt1')
        primitive.result = 0
        self.assertEqual(p2e(primitive), 'Evt7')
        primitive.result = 1
        self.assertEqual(p2e(primitive), 'Evt8')

        primitive = A_RELEASE()
        primitive.result = None
        self.assertEqual(p2e(primitive), 'Evt11')
        primitive.result = 'affirmative'
        self.assertEqual(p2e(primitive), 'Evt14')

        primitive = A_ABORT()
        self.assertEqual(p2e(primitive), 'Evt15')

        primitive = P_DATA()
        self.assertEqual(p2e(primitive), 'Evt9')

        with self.assertRaises(ValueError):
            p2e('TEST')
Ejemplo n.º 4
0
    def CheckRelease(self):
        """Checks for release request from the remote AE. Upon reception of
        the request a confirmation is sent"""
        rel = self.dul.peek_next_pdu()
        if rel.__class__ == A_RELEASE:
            # Make sure this is a A-RELEASE request primitive
            if rel.result == 'affirmative':
                return False

            self.dul.receive_pdu(wait=False)
            release_rsp = A_RELEASE()
            release_rsp.result = "affirmative"
            self.dul.send_pdu(release_rsp)

            return True

        return False
Ejemplo n.º 5
0
    def release_assoc(self):
        """Release the Association with the peer Application Entity.

        Issues an A-RELEASE request primitive to the DICOM UL service provider

        The graceful release of an association between two AEs shall be
        performed through ACSE A-RELEASE request, indication, response and
        confirmation primitives.

        Requests the release of the associations and waits for confirmation.
        A-RELEASE always gives a reason of 'normal' and a result of
        'affirmative'.

        Returns
        -------
        pynetdicom3.pdu_primitives.PDU
            The A-RELEASE response primitive
        """
        LOGGER.info("Releasing Association")
        primitive = A_RELEASE()
        self.dul.send_pdu(primitive)

        return self.dul.receive_pdu(wait=True, timeout=self.acse_timeout)