[GATE FIX] Fix unit tests failing on bionic CI nodes

Due to lack of 'os' module mock, if /etc/init
does not exist the unit test will fail.

This change fixes that by properly mocking
'os' module like other resource_map tests do.

Change-Id: I6b63a1536a51a19b93b8f78ed93ad42b46cd6c9a
This commit is contained in:
Rodrigo Barbieri 2019-07-15 13:21:45 -03:00
parent 2e2d19f7c7
commit a190b7f09a
1 changed files with 6 additions and 2 deletions

View File

@ -497,17 +497,21 @@ class NovaComputeUtilsTests(CharmTestCase):
self.assertEqual(set(ex[k]['services']),
set(result[k]['services']))
@patch.object(utils, 'os')
@patch.object(utils, 'nova_metadata_requirement')
@patch.object(utils, 'network_manager')
def test_resource_map_neutron(self, net_man, en_meta):
def test_resource_map_neutron(self, net_man, en_meta, _os):
self.os_release.return_value = 'diablo'
_os.path.exists.return_value = True
self._test_resource_map_neutron(net_man, en_meta, 'libvirt-bin')
@patch.object(utils, 'os')
@patch.object(utils, 'nova_metadata_requirement')
@patch.object(utils, 'network_manager')
def test_resource_map_neutron_yakkety(self, net_man, en_meta,):
def test_resource_map_neutron_yakkety(self, net_man, en_meta, _os):
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'yakkety'}
self.os_release.return_value = 'diablo'
_os.path.exists.return_value = True
self._test_resource_map_neutron(net_man, en_meta, 'libvirtd')
@patch.object(utils, 'nova_metadata_requirement')