Merge ~addyess/charm-sudo-pair:lp1863743-run_action_updates_workload_status into charm-sudo-pair:master

Proposed by Adam Dyess
Status: Merged
Approved by: Chris Sanders
Approved revision: de75f724f06f00b1a7b67696f997fa6d1232df59
Merged at revision: de75f724f06f00b1a7b67696f997fa6d1232df59
Proposed branch: ~addyess/charm-sudo-pair:lp1863743-run_action_updates_workload_status
Merge into: charm-sudo-pair:master
Diff against target: 47 lines (+21/-2)
2 files modified
actions/actions.py (+4/-2)
tests/unit/test_actions.py (+17/-0)
Reviewer Review Type Date Requested Status
Chris Sanders (community) Approve
Ryan Farrell (community) Approve
Review via email: mp+387053@code.launchpad.net

Commit message

[Bug 1863743] Resolve issue where workload status isn't updated after remove-sudopair action

To post a comment you must log in.
Revision history for this message
Ryan Farrell (whereisrysmind) wrote :

Nice unit test, Looks good. +1

review: Approve
Revision history for this message
Adam Dyess (addyess) wrote :
Revision history for this message
Chris Sanders (chris.sanders) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/actions/actions.py b/actions/actions.py
2index ccf3ffc..1cb455c 100755
3--- a/actions/actions.py
4+++ b/actions/actions.py
5@@ -16,7 +16,7 @@
6 import os
7 import sys
8
9-from charmhelpers.core.hookenv import action_fail, action_set
10+from charmhelpers.core.hookenv import action_fail, action_set, status_set
11
12
13 sys.path.append("lib")
14@@ -28,7 +28,9 @@ def remove():
15 """Remove sudo-pair config and binaries."""
16 sph = libsudopair.SudoPairHelper()
17 sph.deconfigure()
18- action_set({"message": "Successfully removed sudo-pair config and binaries"})
19+ msg = "Successfully removed sudo-pair config and binaries"
20+ action_set({"message": msg})
21+ status_set('active', msg)
22
23
24 # A dictionary of all the defined actions to callables (which take
25diff --git a/tests/unit/test_actions.py b/tests/unit/test_actions.py
26new file mode 100644
27index 0000000..c2da297
28--- /dev/null
29+++ b/tests/unit/test_actions.py
30@@ -0,0 +1,17 @@
31+import os
32+import sys
33+import unittest.mock as mock
34+action_path = os.path.join(os.path.dirname(__file__), '..', '..', 'actions')
35+sys.path.append(action_path)
36+import actions # NOQA
37+
38+
39+@mock.patch('libsudopair.SudoPairHelper')
40+@mock.patch('actions.action_set')
41+@mock.patch('actions.status_set')
42+def test_remove_action(status_set, action_set, sudo_pair_helper):
43+ actions.remove()
44+ msg = 'Successfully removed sudo-pair config and binaries'
45+ action_set.assert_called_with({'message': msg})
46+ status_set.assert_called_with('active', msg)
47+ sudo_pair_helper().deconfigure.assert_called()

Subscribers

People subscribed via source and target branches