def test_get_vpp_interface(self): def test_execute(name, *args, **kwargs): if 'systemctl' in name: return None, None if 'vppctl' in name: return _VPPCTL_OUTPUT, None self.stub_out('oslo_concurrency.processutils.execute', test_execute) int_info = utils._get_vpp_interface('0000:00:09.0') self.assertIsNotNone(int_info) self.assertEqual('GigabitEthernet0/9/0', int_info['name']) self.assertEqual('1', int_info['index']) self.assertIsNone(utils._get_vpp_interface(None)) self.assertIsNone(utils._get_vpp_interface('0000:01:09.0')) self.assertRaises(utils.VppException, utils._get_vpp_interface, '0000:09.0')
def test_get_vpp_interface(self): def test_execute(name, *args, **kwargs): if 'systemctl' in name: return None, None if 'vppctl' in name: return _VPPCTL_OUTPUT, None self.stub_out('oslo_concurrency.processutils.execute', test_execute) int_info = utils._get_vpp_interface('0000:00:09.0') self.assertIsNotNone(int_info) self.assertEqual('GigabitEthernet0/9/0', int_info['name']) self.assertEqual('1', int_info['index']) self.assertIsNone(utils._get_vpp_interface(None)) self.assertIsNone(utils._get_vpp_interface('0000:01:09.0')) self.assertRaises(utils.VppException, utils._get_vpp_interface, '0000:09.0')
def test_get_vpp_interface_name_multiple_iterations(self, mock_execute): self.assertIsNone(utils._get_vpp_interface('0000:00:09.0', 2, 1)) self.assertEqual(4, mock_execute.call_count)
def test_get_vpp_interface_name_multiple_iterations(self, mock_execute): self.assertIsNone(utils._get_vpp_interface('0000:00:09.0', 2, 1)) self.assertEqual(4, mock_execute.call_count)