def test_read_invalid_data_len(self):
     '''raise assert error if data size is smaller than required size'''
     buf = bytearray(32)
     with self.assertRaises(AssertionError) as context:
         read_rta_oper_state(buf)
     self.assertTrue('length of data is smaller than RTATTR_START_OFFSET' in
                     str(context.exception))
Exemple #2
0
 def test_read_invalid_data_len(self):
     """raise assert error if data size is smaller than required size"""
     buf = bytearray(32)
     with self.assertRaises(AssertionError) as context:
         read_rta_oper_state(buf)
     self.assertTrue("length of data is smaller than RTATTR_START_OFFSET" in
                     str(context.exception))
Exemple #3
0
 def test_read_invalid_rta_ifname_none(self):
     """read_rta_oper_state returns none if ifname is none"""
     buf = bytearray(40)
     struct.pack_into("HHc", buf, RTATTR_START_OFFSET, 5, 16,
                      int_to_bytes(OPER_DOWN))
     interface_state = read_rta_oper_state(buf)
     self.assertIsNone(interface_state)
 def test_read_invalid_rta_ifname_none(self):
     '''read_rta_oper_state returns none if ifname is none'''
     buf = bytearray(40)
     struct.pack_into("HHc", buf, RTATTR_START_OFFSET, 5, 16,
                      int_to_bytes(OPER_DOWN))
     interface_state = read_rta_oper_state(buf)
     self.assertIsNone(interface_state)
Exemple #5
0
 def test_read_invalid_rta_operstate_none(self):
     """read_rta_oper_state returns none if operstate is none"""
     ifname = "eth0"
     buf = bytearray(40)
     bytes = ifname.encode("utf-8")
     struct.pack_into("HH4s", buf, RTATTR_START_OFFSET, 8, 3, bytes)
     interface_state = read_rta_oper_state(buf)
     self.assertIsNone(interface_state)
 def test_read_invalid_rta_operstate_none(self):
     '''read_rta_oper_state returns none if operstate is none'''
     ifname = "eth0"
     buf = bytearray(40)
     bytes = ifname.encode("utf-8")
     struct.pack_into("HH4s", buf, RTATTR_START_OFFSET, 8, 3, bytes)
     interface_state = read_rta_oper_state(buf)
     self.assertIsNone(interface_state)
Exemple #7
0
 def test_read_rta_oper_state(self):
     '''read_rta_oper_state could parse netlink message and extract data'''
     ifname = "eth0"
     bytes = ifname.encode("utf-8")
     buf = bytearray(48)
     struct.pack_into("HH4sHHc", buf, RTATTR_START_OFFSET, 8, 3, bytes, 5,
                      16, int_to_bytes(OPER_DOWN))
     interface_state = read_rta_oper_state(buf)
     self.assertEqual(interface_state.ifname, ifname)
     self.assertEqual(interface_state.operstate, OPER_DOWN)
 def test_read_rta_oper_state(self):
     '''read_rta_oper_state could parse netlink message and extract data'''
     ifname = "eth0"
     bytes = ifname.encode("utf-8")
     buf = bytearray(48)
     struct.pack_into("HH4sHHc", buf, RTATTR_START_OFFSET, 8, 3, bytes, 5,
                      16, int_to_bytes(OPER_DOWN))
     interface_state = read_rta_oper_state(buf)
     self.assertEqual(interface_state.ifname, ifname)
     self.assertEqual(interface_state.operstate, OPER_DOWN)
Exemple #9
0
 def test_read_none_data(self):
     """read_rta_oper_state raises assert error if data is none"""
     data = None
     with self.assertRaises(AssertionError) as context:
         read_rta_oper_state(data)
     self.assertEqual("data is none", str(context.exception))
Exemple #10
0
 def test_read_none_data(self):
     '''read_rta_oper_state raises assert error if data is none'''
     data = None
     with self.assertRaises(AssertionError) as context:
         read_rta_oper_state(data)
     self.assertTrue('data is none', str(context.exception))
Exemple #11
0
 def test_read_none_data(self):
     '''read_rta_oper_state raises assert error if data is none'''
     data = None
     with self.assertRaises(AssertionError) as context:
         read_rta_oper_state(data)
     self.assertTrue('data is none', str(context.exception))