def test_new_encode_a_p_abort(self): """ Check encoding using new generic method """ pdu = A_ABORT_RQ() pdu.Decode(a_p_abort) s = pdu.encode() self.assertEqual(s, a_p_abort)
def test_a_p_abort_stream_encode(self): """ Check encoding an a_abort produces the correct output """ pdu = A_ABORT_RQ() pdu.Decode(a_p_abort) s = pdu.Encode() self.assertEqual(s, a_p_abort)
def test_string_output(self): """Test the string output""" pdu = A_ABORT_RQ() pdu.Decode(a_abort) self.assertTrue("0x07" in pdu.__str__()) self.assertTrue("4 bytes" in pdu.__str__()) self.assertTrue("DUL service-user" in pdu.__str__())
def test_generic_encode(self): """ Check using the new pdu.encode produces the correct output """ pdu = A_ABORT_RQ() pdu.Decode(a_abort) s = pdu.Encode() t = pdu.encode() self.assertEqual(s, t)
def test_to_a_p_abort_primitive(self): """ Check converting PDU to a_p_abort primitive """ pdu = A_ABORT_RQ() pdu.Decode(a_p_abort) primitive = pdu.ToParams() self.assertTrue(isinstance(primitive, A_P_ABORT)) self.assertEqual(primitive.provider_reason, 4)
def test_source_str(self): """ Check the source str returns correct values """ pdu = A_ABORT_RQ() pdu.Decode(a_abort) pdu.source = 0 self.assertEqual(pdu.source_str, 'DUL service-user') pdu.source = 2 self.assertEqual(pdu.source_str, 'DUL service-provider')
def test_a_p_abort_from_primitive(self): """ Check converting PDU to primitive """ orig_pdu = A_ABORT_RQ() orig_pdu.Decode(a_p_abort) primitive = orig_pdu.ToParams() new_pdu = A_ABORT_RQ() new_pdu.FromParams(primitive) self.assertEqual(new_pdu, orig_pdu)
def test_a_p_abort_stream_decode_values_types(self): """ Check decoding the a_abort stream produces the correct objects """ pdu = A_ABORT_RQ() pdu.Decode(a_p_abort) self.assertEqual(pdu.pdu_type, 0x07) self.assertEqual(pdu.pdu_length, 4) self.assertEqual(pdu.source, 2) self.assertEqual(pdu.reason_diagnostic, 4) self.assertTrue(isinstance(pdu.pdu_type, int)) self.assertTrue(isinstance(pdu.pdu_length, int)) self.assertTrue(isinstance(pdu.source, int)) self.assertTrue(isinstance(pdu.reason_diagnostic, int))
def test_reason_str(self): """ Check the reaspm str returns correct values """ pdu = A_ABORT_RQ() pdu.Decode(a_abort) pdu.source = 2 pdu.reason_diagnostic = 0 self.assertEqual(pdu.reason_str, "No reason given") pdu.reason_diagnostic = 1 self.assertEqual(pdu.reason_str, "Unrecognised PDU") pdu.reason_diagnostic = 2 self.assertEqual(pdu.reason_str, "Unexpected PDU") pdu.reason_diagnostic = 3 self.assertEqual(pdu.reason_str, "Reserved") pdu.reason_diagnostic = 4 self.assertEqual(pdu.reason_str, "Unrecognised PDU parameter") pdu.reason_diagnostic = 5 self.assertEqual(pdu.reason_str, "Unexpected PDU parameter") pdu.reason_diagnostic = 6 self.assertEqual(pdu.reason_str, "Invalid PDU parameter value")