From 8900ce1958e2d2c51e9b4622c75edc17f068f73c Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 3 Aug 2016 11:52:23 +0200 Subject: [PATCH] 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 --- os_brick/tests/remotefs/test_remotefs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os_brick/tests/remotefs/test_remotefs.py b/os_brick/tests/remotefs/test_remotefs.py index 6d7b1cf..727d61b 100644 --- a/os_brick/tests/remotefs/test_remotefs.py +++ b/os_brick/tests/remotefs/test_remotefs.py @@ -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'