summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2017-05-18 15:07:55 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2017-05-18 15:07:55 -0400
commitafdddf8eea34866b43d1fc92624f9ac175802f36 (patch)
tree8e61fd8c5c859a8e7bcbca2a047aa53e660be876
parent951863c211ab0f8c43a9443d080dbbe0f6b454a6 (diff)
downloadcloud-init-git-afdddf8eea34866b43d1fc92624f9ac175802f36.tar.gz
cloudstack: fix tests to avoid accessing /var/lib/NetworkManager
on centos/fedora/rhel, /var/lib/NetworkManager has mode 700, causing the cloudstack unit tests to fail when run as a non-root user. This mocks out get_latest_lease so that we no longer try to read dhcp lease information during the unit tests.
-rw-r--r--tests/unittests/test_datasource/test_cloudstack.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/unittests/test_datasource/test_cloudstack.py b/tests/unittests/test_datasource/test_cloudstack.py
index 1d3d2f19..e94aad61 100644
--- a/tests/unittests/test_datasource/test_cloudstack.py
+++ b/tests/unittests/test_datasource/test_cloudstack.py
@@ -16,10 +16,15 @@ class TestCloudStackPasswordFetching(TestCase):
self.patches.enter_context(mock.patch('{0}.ec2'.format(mod_name)))
self.patches.enter_context(mock.patch('{0}.uhelp'.format(mod_name)))
default_gw = "192.201.20.0"
- mod_name = 'cloudinit.sources.DataSourceCloudStack.get_default_gateway'
+ get_latest_lease = mock.MagicMock(return_value=None)
+ self.patches.enter_context(mock.patch(
+ 'cloudinit.sources.DataSourceCloudStack.get_latest_lease',
+ get_latest_lease))
+
get_default_gw = mock.MagicMock(return_value=default_gw)
- self.patches.enter_context(
- mock.patch(mod_name, get_default_gw))
+ self.patches.enter_context(mock.patch(
+ 'cloudinit.sources.DataSourceCloudStack.get_default_gateway',
+ get_default_gw))
def _set_password_server_response(self, response_string):
subp = mock.MagicMock(return_value=(response_string, ''))