def test_assignment(self): """ Check assignment works correctly """ primitive = A_ABORT() primitive.abort_source = 0 assert primitive.abort_source == 0 primitive.abort_source = 2 assert primitive.abort_source == 2
def send_abort(self, source): """Send an A-ABORT request to the peer. Parameters ---------- source : int The source of the abort request - ``0x00`` - the DUL service user - ``0x02`` - the DUL service provider Raises ------ ValueError If the `source` value is invalid. """ if source not in [0x00, 0x02]: raise ValueError("Invalid 'source' parameter value") # The following parameters must be set for an A-ABORT primitive # (* sent in A-ABORT PDU): # Abort Source* # Provider Reason* (not significant with source 0x00) primitive = A_ABORT() primitive.abort_source = source self.dul.send_pdu(primitive) self.assoc.is_aborted = True self.assoc.is_established = False
def test_exceptions(self): """ Check incorrect types/values for properties raise exceptions """ primitive = A_ABORT() with pytest.raises(ValueError): primitive.abort_source = 1 with pytest.raises(ValueError): primitive.abort_source
def test_conversion(self): """ Check conversion to a PDU produces the correct output """ primitive = A_ABORT() primitive.abort_source = 0 pdu = A_ABORT_RQ() pdu.from_primitive(primitive) data = pdu.encode() assert data == b"\x07\x00\x00\x00\x00\x04\x00\x00\x00\x00"