Fix weak test_vzstorage_with_mds_list

Existing test_vzstorage_with_mds_list in
os_brick.tests.remotefs.test_remotefs.RemoteFsClientTestCase is not
mocking the path exists method and this creates problems in some patches
in gate-os-brick-python27-ubuntu-xenial since we end up getting this
call

 call('cp', '-rf', '/tmp/fake_dir/', '/etc/pstorage/clusters/qwe',
 root_helper='true', run_as_root=True),

instead of the one we were expecting

 call('cp', '-f', '/tmp/fake_dir/bs_list',
 '/etc/pstorage/clusters/qwe/bs_list', root_helper='true',
 run_as_root=True),

This patch just mocks the exists method to make sure we always go
through the same execution path.

Change-Id: Iac1215e8e81d83440fbe0b4d383fc0a27e02def7
This commit is contained in:
Gorka Eguileor 2016-08-03 11:52:23 +02:00
parent 45184cb9b0
commit 8900ce1958
1 changed files with 2 additions and 1 deletions

View File

@ -78,9 +78,10 @@ class RemoteFsClientTestCase(base.TestCase):
run_as_root=True)]
self.mock_execute.assert_has_calls(calls)
@mock.patch('os.path.exists', return_value=False)
@mock.patch.object(remotefs.RemoteFsClient, '_read_mounts',
return_value=[])
def test_vzstorage_with_mds_list(self, mock_read_mounts):
def test_vzstorage_with_mds_list(self, mock_read_mounts, mock_exists):
client = remotefs.RemoteFsClient("vzstorage", root_helper='true',
vzstorage_mount_point_base='/mnt')
cluster_name = 'qwe'