Beispiel #1
0
    def test_new_encode(self):
        """ Check encoding using new generic method """
        pdu = A_RELEASE_RP()
        pdu.Decode(a_release_rp)
        s = pdu.encode()

        self.assertEqual(s, a_release_rp)
Beispiel #2
0
    def test_stream_encode(self):
        """ Check encoding an release_rp produces the correct output """
        pdu = A_RELEASE_RP()
        pdu.Decode(a_release_rp)
        s = pdu.Encode()

        self.assertEqual(s, a_release_rp)
Beispiel #3
0
    def test_generic_encode(self):
        """ Check using the new pdu.encode produces the correct output """
        pdu = A_RELEASE_RP()
        pdu.Decode(a_release_rp)
        s = pdu.Encode()
        t = pdu.encode()

        self.assertEqual(s, t)
Beispiel #4
0
    def test_to_primitive(self):
        """ Check converting PDU to primitive """
        pdu = A_RELEASE_RP()
        pdu.Decode(a_release_rp)

        primitive = pdu.ToParams()

        self.assertEqual(primitive.reason, "normal")
        self.assertEqual(primitive.result, "affirmative")
Beispiel #5
0
    def test_stream_decode_values_types(self):
        """ Check decoding the release_rp stream produces the correct objects """
        pdu = A_RELEASE_RP()
        pdu.Decode(a_release_rp)

        self.assertEqual(pdu.pdu_type, 0x06)
        self.assertEqual(pdu.pdu_length, 4)
        self.assertEqual(pdu.get_length(), 10)
        self.assertTrue(isinstance(pdu.pdu_type, int))
        self.assertTrue(isinstance(pdu.pdu_length, int))
Beispiel #6
0
    def test_from_primitive(self):
        """ Check converting PDU to primitive """
        orig_pdu = A_RELEASE_RP()
        orig_pdu.Decode(a_release_rp)

        primitive = orig_pdu.ToParams()

        new_pdu = A_RELEASE_RP()
        new_pdu.FromParams(primitive)

        self.assertEqual(new_pdu, orig_pdu)
Beispiel #7
0
 def test_string_output(self):
     """Test the string output"""
     pdu = A_RELEASE_RP()
     pdu.Decode(a_release_rp)
     self.assertTrue("0x06" in pdu.__str__())
     self.assertTrue("10 bytes" in pdu.__str__())