81a8f48c290bf4cc195ef554ad0afc3ee55c4e3c
[vpp.git] / test / test_papi.py
1 import binascii
2 from framework import VppTestCase
3 from vpp_papi import VPP
4 from socket import inet_pton, AF_INET, AF_INET6
5
6 import json
7
8 """ TestPAPI is a subclass of  VPPTestCase classes.
9
10 Basic test for sanity check of the Python API binding.
11
12 """
13
14
15 class TestPAPI(VppTestCase):
16     """ PAPI Test Case """
17
18     @classmethod
19     def setUpClass(cls):
20         super(TestPAPI, cls).setUpClass()
21         cls.v = cls.vapi.papi
22
23     def test_show_version(self):
24         """ show version """
25         rv = self.v.show_version()
26         self.assertEqual(rv.retval, 0)
27
28     def test_show_version_invalid_param(self):
29         """ show version - invalid parameters"""
30         self.assertRaises(ValueError, self.v.show_version, foobar='foo')
31
32     def test_u8_array(self):
33         """ u8 array """
34         rv = self.v.get_node_index(node_name='ip4-lookup')
35         self.assertEqual(rv.retval, 0)
36         node_name = 'X' * 100
37         self.assertRaises(ValueError, self.v.get_node_index,
38                           node_name=node_name)