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
=== modified file 'tests/contrib/network/test_ufw.py'
--- tests/contrib/network/test_ufw.py 2015-09-03 14:22:08 +0000
+++ tests/contrib/network/test_ufw.py 2016-06-17 15:08:32 +0000
@@ -42,7 +42,8 @@
42class TestUFW(unittest.TestCase):42class TestUFW(unittest.TestCase):
43 @mock.patch('charmhelpers.core.hookenv.log')43 @mock.patch('charmhelpers.core.hookenv.log')
44 @mock.patch('subprocess.check_output')44 @mock.patch('subprocess.check_output')
45 def test_enable_ok(self, check_output, log):45 @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
46 def test_enable_ok(self, modprobe, check_output, log):
46 msg = 'Firewall is active and enabled on system startup\n'47 msg = 'Firewall is active and enabled on system startup\n'
47 check_output.return_value = msg48 check_output.return_value = msg
48 self.assertTrue(ufw.enable())49 self.assertTrue(ufw.enable())
@@ -56,7 +57,8 @@
5657
57 @mock.patch('charmhelpers.core.hookenv.log')58 @mock.patch('charmhelpers.core.hookenv.log')
58 @mock.patch('subprocess.check_output')59 @mock.patch('subprocess.check_output')
59 def test_enable_fail(self, check_output, log):60 @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
61 def test_enable_fail(self, modprobe, check_output, log):
60 msg = 'neneene\n'62 msg = 'neneene\n'
61 check_output.return_value = msg63 check_output.return_value = msg
62 self.assertFalse(ufw.enable())64 self.assertFalse(ufw.enable())
@@ -307,7 +309,9 @@
307 @mock.patch('os.path.isdir')309 @mock.patch('os.path.isdir')
308 @mock.patch('subprocess.call')310 @mock.patch('subprocess.call')
309 @mock.patch('subprocess.check_output')311 @mock.patch('subprocess.check_output')
310 def test_no_ip6_tables(self, check_output, call, isdir, log, is_enabled):312 @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
313 def test_no_ip6_tables(self, modprobe, check_output, call, isdir, log,
314 is_enabled):
311 def c(*args, **kwargs):315 def c(*args, **kwargs):
312 if args[0] == ['lsmod']:316 if args[0] == ['lsmod']:
313 return LSMOD_NO_IP6317 return LSMOD_NO_IP6
@@ -395,7 +399,8 @@
395 @mock.patch('charmhelpers.contrib.network.ufw.is_enabled')399 @mock.patch('charmhelpers.contrib.network.ufw.is_enabled')
396 @mock.patch('os.path.isdir')400 @mock.patch('os.path.isdir')
397 @mock.patch('subprocess.check_output')401 @mock.patch('subprocess.check_output')
398 def test_with_ipv6(self, check_output, isdir, is_enabled, log):402 @mock.patch('charmhelpers.contrib.network.ufw.modprobe')
403 def test_with_ipv6(self, modprobe, check_output, isdir, is_enabled, log):
399 def c(*args, **kwargs):404 def c(*args, **kwargs):
400 if args[0] == ['lsmod']:405 if args[0] == ['lsmod']:
401 return LSMOD_IP6406 return LSMOD_IP6

Subscribers

People subscribed via source and target branches