Example #1
0
    def test_result_code(self):
        """
        Test we can encode and decode result codes
        """
        self._compare_avp(
            avp.ResultCodeAVP(268, avp.ResultCode.DIAMETER_SUCCESS),
            memoryview(b'\x00\x00\x01\x0c\x00\x00\x00\x0c\x00\x00\x07\xd1'))

        # Test a value we haven't defined
        self._compare_avp(
            avp.ResultCodeAVP(268, 1337),
            memoryview(b'\x00\x00\x01\x0c\x00\x00\x00\x0c\x00\x00\x059'))
Example #2
0
    def test_result_code(self):
        """
        Tests we can create an AVP with a code and it defaults to the defaults
        vendor.
        """
        result_avp = avp.AVP('Result-Code', avp.ResultCode.DIAMETER_SUCCESS)
        self.assertEqual(result_avp.value, avp.ResultCode.DIAMETER_SUCCESS)

        self._compare_avp(
            avp.AVP('Result-Code', avp.ResultCode.DIAMETER_SUCCESS),
            avp.ResultCodeAVP(268,
                              2001,
                              vendor=avp.VendorId.DEFAULT,
                              flags=avp.FLAG_MANDATORY,
                              name='Result-Code'))