summaryrefslogtreecommitdiff
path: root/tests/unittests/test_net.py
diff options
context:
space:
mode:
authorJason Zions (MSFT) <jasonzio@microsoft.com>2019-04-18 21:23:36 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-04-18 21:23:36 +0000
commitc8c32515778983d244126d4e359be9e91b3ce9e5 (patch)
tree81ccd800b9223ff36f9e6a7fe18589ae10e73caf /tests/unittests/test_net.py
parent947d3c20891815f164f4c7a8884d1f02ae4a9c5b (diff)
downloadvyos-cloud-init-c8c32515778983d244126d4e359be9e91b3ce9e5.tar.gz
vyos-cloud-init-c8c32515778983d244126d4e359be9e91b3ce9e5.zip
test_azure: mock util.SeLinuxGuard where needed
Mock util.SeLinuxGuard to do nothing within tests that mock functions used by the guard, when those mocks confuse the guard. This has no impact when executing unit tests on systems which do not enable selinux (e.g. Ubuntu). LP: #1825253
Diffstat (limited to 'tests/unittests/test_net.py')
-rw-r--r--tests/unittests/test_net.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index fd03deb6..ca6ef97d 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -3269,9 +3269,12 @@ class TestNetplanPostcommands(CiTestCase):
mock_netplan_generate.assert_called_with(run=True)
mock_net_setup_link.assert_called_with(run=True)
+ @mock.patch('cloudinit.util.SeLinuxGuard')
@mock.patch.object(netplan, "get_devicelist")
@mock.patch('cloudinit.util.subp')
- def test_netplan_postcmds(self, mock_subp, mock_devlist):
+ def test_netplan_postcmds(self, mock_subp, mock_devlist, mock_sel):
+ mock_sel.__enter__ = mock.Mock(return_value=False)
+ mock_sel.__exit__ = mock.Mock()
mock_devlist.side_effect = [['lo']]
tmp_dir = self.tmp_dir()
ns = network_state.parse_net_config_data(self.mycfg,