def test_get_device_id_exception(self):
     mocked_open = mock.mock_open()
     mocked_open.side_effect = IOError
     with mock.patch('os_net_config.utils.open', mocked_open, create=True):
         device = utils.get_device_id('nic2')
         self.assertEqual(None, device)
Esempio n. 2
0
 def test_get_device_id_exception(self):
     mocked_open = mock.mock_open()
     mocked_open.side_effect = IOError
     with mock.patch('os_net_config.utils.open', mocked_open, create=True):
         device = utils.get_device_id('nic2')
         self.assertEqual(None, device)
 def test_get_device_id_success(self):
     mocked_open = mock.mock_open(read_data='0x1003\n')
     with mock.patch('os_net_config.utils.open', mocked_open, create=True):
         device = utils.get_device_id('nic2')
         self.assertEqual('0x1003', device)
Esempio n. 4
0
 def test_get_device_id_success(self):
     mocked_open = mock.mock_open(read_data='0x1003\n')
     with mock.patch('os_net_config.utils.open', mocked_open, create=True):
         device = utils.get_device_id('nic2')
         self.assertEqual('0x1003', device)