示例#1
0
 def test_netlink_read_timeout(self, m_select, m_socket):
     """read_netlink_socket should timeout if nothing to read"""
     m_select.return_value = [], None, None
     data = read_netlink_socket(m_socket, 1)
     m_select.assert_called_with([m_socket], [], [], 1)
     self.assertEqual(m_socket.recv.call_count, 0)
     self.assertIsNone(data)
示例#2
0
 def test_netlink_read_timeout(self, m_select, m_socket):
     '''read_netlink_socket should timeout if nothing to read'''
     m_select.return_value = [], None, None
     data = read_netlink_socket(m_socket, 1)
     m_select.assert_called_with([m_socket], [], [], 1)
     self.assertEqual(m_socket.recv.call_count, 0)
     self.assertIsNone(data)
示例#3
0
 def test_read_netlink_socket(self, m_select, m_socket):
     """read_netlink_socket able to receive data"""
     data = "netlinktest"
     m_select.return_value = [m_socket], None, None
     m_socket.recv.return_value = data
     recv_data = read_netlink_socket(m_socket, 2)
     m_select.assert_called_with([m_socket], [], [], 2)
     m_socket.recv.assert_called_with(MAX_SIZE)
     self.assertIsNotNone(recv_data)
     self.assertEqual(recv_data, data)
示例#4
0
 def test_read_netlink_socket(self, m_select, m_socket):
     '''read_netlink_socket able to receive data'''
     data = 'netlinktest'
     m_select.return_value = [m_socket], None, None
     m_socket.recv.return_value = data
     recv_data = read_netlink_socket(m_socket, 2)
     m_select.assert_called_with([m_socket], [], [], 2)
     m_socket.recv.assert_called_with(MAX_SIZE)
     self.assertIsNotNone(recv_data)
     self.assertEqual(recv_data, data)
示例#5
0
 def test_read_invalid_socket(self):
     """read_netlink_socket raises assert error if socket is invalid"""
     socket = None
     with self.assertRaises(AssertionError) as context:
         read_netlink_socket(socket, 1)
     self.assertTrue("netlink socket is none" in str(context.exception))
示例#6
0
 def test_read_invalid_socket(self):
     '''read_netlink_socket raises assert error if socket is invalid'''
     socket = None
     with self.assertRaises(AssertionError) as context:
         read_netlink_socket(socket, 1)
     self.assertTrue('netlink socket is none' in str(context.exception))