X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fpython%2Fvpp_papi%2Ftests%2Ftest_vpp_serializer.py;fp=src%2Fvpp-api%2Fpython%2Fvpp_papi%2Ftests%2Ftest_vpp_serializer.py;h=21b23bdf6c21ec2d4d1b4063392a83eba4de1d3b;hb=5395c6a07996b9d852ce1e942bd2b3c094b89d27;hp=317fea7269a50592221dc73b4b09e098f5860917;hpb=18a71d8af56f4a70c9257608eb6e71b9cdc9f2ae;p=vpp.git diff --git a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py index 317fea7269a..21b23bdf6c2 100755 --- a/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/tests/test_vpp_serializer.py @@ -47,7 +47,6 @@ class TestLimits(unittest.TestCase): self.assertEqual(nt.name, 'foobar') self.assertEqual(len(nt.name), len('foobar')) - def test_limit(self): limited_type = VPPType('limited_type_t', [['string', 'name', 0, {'limit': 16}]]) @@ -105,6 +104,7 @@ class TestDefaults(unittest.TestCase): self.assertEqual(len(b), size) self.assertEqual(nt.e, 1) + class TestAddType(unittest.TestCase): def test_union(self): @@ -201,7 +201,6 @@ class TestAddType(unittest.TestCase): [['vl_api_address_family_t', 'af'], ['vl_api_address_union_t', 'un']]) - prefix = VPPType('vl_api_prefix_t', [['vl_api_address_t', 'address'], ['u8', 'len']]) @@ -274,7 +273,6 @@ class TestAddType(unittest.TestCase): self.assertTrue(isinstance(nt.address, IPv4Interface)) self.assertEqual(str(nt.address), '1.2.3.4/24') - def test_recursive_address(self): af = VPPEnumType('vl_api_address_family_t', [["ADDRESS_IP4", 0], ["ADDRESS_IP6", 1], @@ -557,7 +555,6 @@ class TestAddType(unittest.TestCase): self.assertEqual(len(b), 20) - def test_lisp(self): VPPEnumType('vl_api_eid_type_t', [["EID_TYPE_API_PREFIX", 0], @@ -609,5 +606,27 @@ class TestAddType(unittest.TestCase): self.assertIsNone(nt.address.prefix) +class TestVppSerializerLogging(unittest.TestCase): + + def test_logger(self): + # test logger name 'vpp_papi.serializer' + with self.assertRaises(VPPSerializerValueError) as ctx: + with self.assertLogs('vpp_papi.serializer', level='DEBUG') as cm: + u = VPPUnionType('vl_api_eid_address_t', + [["vl_api_prefix_t", "prefix"], + ["vl_api_mac_address_t", "mac"], + ["vl_api_nsh_t", "nsh"]]) + self.assertEqual(cm.output, ["DEBUG:vpp_papi.serializer:Unknown union type vl_api_prefix_t"]) + + # test parent logger name 'vpp_papi' + with self.assertRaises(VPPSerializerValueError) as ctx: + with self.assertLogs('vpp_papi', level='DEBUG') as cm: + u = VPPUnionType('vl_api_eid_address_t', + [["vl_api_prefix_t", "prefix"], + ["vl_api_mac_address_t", "mac"], + ["vl_api_nsh_t", "nsh"]]) + self.assertEqual(cm.output, ["DEBUG:vpp_papi.serializer:Unknown union type vl_api_prefix_t"]) + + if __name__ == '__main__': unittest.main()