def test_exceptions(self): """ Check incorrect types/values for properties raise exceptions """ primitive = A_P_ABORT() with pytest.raises(ValueError): primitive.provider_reason = 3 with pytest.raises(ValueError): primitive.provider_reason
def test_conversion(self): """ Check conversion to a PDU produces the correct output """ primitive = A_P_ABORT() primitive.provider_reason = 4 pdu = A_ABORT_RQ() pdu.from_primitive(primitive) data = pdu.encode() self.assertEqual(data, b"\x07\x00\x00\x00\x00\x04\x00\x00\x02\x04")
def test_assignment(self): """ Check assignment works correctly """ primitive = A_P_ABORT() primitive.provider_reason = 0 self.assertEqual(primitive.provider_reason, 0) primitive.provider_reason = 1 self.assertEqual(primitive.provider_reason, 1) primitive.provider_reason = 2 self.assertEqual(primitive.provider_reason, 2) primitive.provider_reason = 4 self.assertEqual(primitive.provider_reason, 4) primitive.provider_reason = 5 self.assertEqual(primitive.provider_reason, 5) primitive.provider_reason = 6 self.assertEqual(primitive.provider_reason, 6)