Merge ~larsks/cloud-init:bug/cloudstack-tests into cloud-init:master

Proposed by Lars Kellogg-Stedman on 2017-05-18
Status: Merged
Merged at revision: afdddf8eea34866b43d1fc92624f9ac175802f36
Proposed branch: ~larsks/cloud-init:bug/cloudstack-tests
Merge into: cloud-init:master
Diff against target: 23 lines (+8/-3)
1 file modified
tests/unittests/test_datasource/test_cloudstack.py (+8/-3)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve on 2017-05-18
Scott Moser 2017-05-18 Approve on 2017-05-18
Review via email: mp+324277@code.launchpad.net

Description of the Change

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.

This permits the unit tests to complete on centos/fedora/rhel/etc.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unittests/test_datasource/test_cloudstack.py b/tests/unittests/test_datasource/test_cloudstack.py
2index 1d3d2f1..e94aad6 100644
3--- a/tests/unittests/test_datasource/test_cloudstack.py
4+++ b/tests/unittests/test_datasource/test_cloudstack.py
5@@ -16,10 +16,15 @@ class TestCloudStackPasswordFetching(TestCase):
6 self.patches.enter_context(mock.patch('{0}.ec2'.format(mod_name)))
7 self.patches.enter_context(mock.patch('{0}.uhelp'.format(mod_name)))
8 default_gw = "192.201.20.0"
9- mod_name = 'cloudinit.sources.DataSourceCloudStack.get_default_gateway'
10+ get_latest_lease = mock.MagicMock(return_value=None)
11+ self.patches.enter_context(mock.patch(
12+ 'cloudinit.sources.DataSourceCloudStack.get_latest_lease',
13+ get_latest_lease))
14+
15 get_default_gw = mock.MagicMock(return_value=default_gw)
16- self.patches.enter_context(
17- mock.patch(mod_name, get_default_gw))
18+ self.patches.enter_context(mock.patch(
19+ 'cloudinit.sources.DataSourceCloudStack.get_default_gateway',
20+ get_default_gw))
21
22 def _set_password_server_response(self, response_string):
23 subp = mock.MagicMock(return_value=(response_string, ''))

Subscribers

People subscribed via source and target branches