Merge lp:~freyes/charm-helpers/lp1593036 into lp:charm-helpers

Proposed by Felipe Reyes
Status: Merged
Merged at revision: 589
Proposed branch: lp:~freyes/charm-helpers/lp1593036
Merge into: lp:charm-helpers
Diff against target: 44 lines (+9/-4)
1 file modified
tests/contrib/network/test_ufw.py (+9/-4)
To merge this branch: bzr merge lp:~freyes/charm-helpers/lp1593036
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+297785@code.launchpad.net

Description of the change

Dear Charmers,

This patch fixes the unit test suite for charmhelpers.contrib.network.ufw, this is done mocking charmhelpers.core.kernel.modprobe to make sure the behavior is consistent no matter the environment where the suite is being executed.

Best,

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks good, and the tests that were previously failing are now passing.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/contrib/network/test_ufw.py'
2--- tests/contrib/network/test_ufw.py 2015-09-03 14:22:08 +0000
3+++ tests/contrib/network/test_ufw.py 2016-06-17 15:08:32 +0000
4@@ -42,7 +42,8 @@
5 class TestUFW(unittest.TestCase):
6 @mock.patch('charmhelpers.core.hookenv.log')
7 @mock.patch('subprocess.check_output')
8- def test_enable_ok(self, check_output, log):
9+ @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
10+ def test_enable_ok(self, modprobe, check_output, log):
11 msg = 'Firewall is active and enabled on system startup\n'
12 check_output.return_value = msg
13 self.assertTrue(ufw.enable())
14@@ -56,7 +57,8 @@
15
16 @mock.patch('charmhelpers.core.hookenv.log')
17 @mock.patch('subprocess.check_output')
18- def test_enable_fail(self, check_output, log):
19+ @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
20+ def test_enable_fail(self, modprobe, check_output, log):
21 msg = 'neneene\n'
22 check_output.return_value = msg
23 self.assertFalse(ufw.enable())
24@@ -307,7 +309,9 @@
25 @mock.patch('os.path.isdir')
26 @mock.patch('subprocess.call')
27 @mock.patch('subprocess.check_output')
28- def test_no_ip6_tables(self, check_output, call, isdir, log, is_enabled):
29+ @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
30+ def test_no_ip6_tables(self, modprobe, check_output, call, isdir, log,
31+ is_enabled):
32 def c(*args, **kwargs):
33 if args[0] == ['lsmod']:
34 return LSMOD_NO_IP6
35@@ -395,7 +399,8 @@
36 @mock.patch('charmhelpers.contrib.network.ufw.is_enabled')
37 @mock.patch('os.path.isdir')
38 @mock.patch('subprocess.check_output')
39- def test_with_ipv6(self, check_output, isdir, is_enabled, log):
40+ @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
41+ def test_with_ipv6(self, modprobe, check_output, isdir, is_enabled, log):
42 def c(*args, **kwargs):
43 if args[0] == ['lsmod']:
44 return LSMOD_IP6

Subscribers

People subscribed via source and target branches