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
diff --git a/actions/actions.py b/actions/actions.py
index ccf3ffc..1cb455c 100755
--- a/actions/actions.py
+++ b/actions/actions.py
@@ -16,7 +16,7 @@
16import os16import os
17import sys17import sys
1818
19from charmhelpers.core.hookenv import action_fail, action_set19from charmhelpers.core.hookenv import action_fail, action_set, status_set
2020
2121
22sys.path.append("lib")22sys.path.append("lib")
@@ -28,7 +28,9 @@ def remove():
28 """Remove sudo-pair config and binaries."""28 """Remove sudo-pair config and binaries."""
29 sph = libsudopair.SudoPairHelper()29 sph = libsudopair.SudoPairHelper()
30 sph.deconfigure()30 sph.deconfigure()
31 action_set({"message": "Successfully removed sudo-pair config and binaries"})31 msg = "Successfully removed sudo-pair config and binaries"
32 action_set({"message": msg})
33 status_set('active', msg)
3234
3335
34# A dictionary of all the defined actions to callables (which take36# A dictionary of all the defined actions to callables (which take
diff --git a/tests/unit/test_actions.py b/tests/unit/test_actions.py
35new file mode 10064437new file mode 100644
index 0000000..c2da297
--- /dev/null
+++ b/tests/unit/test_actions.py
@@ -0,0 +1,17 @@
1import os
2import sys
3import unittest.mock as mock
4action_path = os.path.join(os.path.dirname(__file__), '..', '..', 'actions')
5sys.path.append(action_path)
6import actions # NOQA
7
8
9@mock.patch('libsudopair.SudoPairHelper')
10@mock.patch('actions.action_set')
11@mock.patch('actions.status_set')
12def test_remove_action(status_set, action_set, sudo_pair_helper):
13 actions.remove()
14 msg = 'Successfully removed sudo-pair config and binaries'
15 action_set.assert_called_with({'message': msg})
16 status_set.assert_called_with('active', msg)
17 sudo_pair_helper().deconfigure.assert_called()

Subscribers

People subscribed via source and target branches