Merge lp:~corey.bryant/charm-helpers/test_set_os_workload_status_mixed into lp:charm-helpers

Proposed by Corey Bryant
Status: Merged
Merged at revision: 454
Proposed branch: lp:~corey.bryant/charm-helpers/test_set_os_workload_status_mixed
Merge into: lp:charm-helpers
Diff against target: 172 lines (+33/-15)
1 file modified
tests/contrib/openstack/test_openstack_utils.py (+33/-15)
To merge this branch: bzr merge lp:~corey.bryant/charm-helpers/test_set_os_workload_status_mixed
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+271857@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Mostly this is fixing the assertion for test_set_os_workload_status_mixed() since the ordering of the 2nd parameter can vary. Other than that just mocking out some juju_log calls.

Revision history for this message
Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
2--- tests/contrib/openstack/test_openstack_utils.py 2015-09-16 15:00:47 +0000
3+++ tests/contrib/openstack/test_openstack_utils.py 2015-09-21 18:55:31 +0000
4@@ -852,8 +852,9 @@
5 result = openstack.incomplete_relation_data(configs, required_interfaces)
6 self.assertTrue(expected_result in result.keys())
7
8+ @patch.object(openstack, 'juju_log')
9 @patch('charmhelpers.contrib.openstack.utils.status_set')
10- def test_set_os_workload_status_complete(self, status_set):
11+ def test_set_os_workload_status_complete(self, status_set, log):
12 configs = MagicMock()
13 configs.complete_contexts.return_value = ['shared-db',
14 'amqp',
15@@ -866,11 +867,13 @@
16 openstack.set_os_workload_status(configs, required_interfaces)
17 status_set.assert_called_with('active', 'Unit is ready')
18
19+ @patch.object(openstack, 'juju_log')
20 @patch('charmhelpers.contrib.openstack.utils.incomplete_relation_data',
21 return_value={'identity': {'identity-service': {'related': True}}})
22 @patch('charmhelpers.contrib.openstack.utils.status_set')
23 def test_set_os_workload_status_related_incomplete(self, status_set,
24- incomplete_relation_data):
25+ incomplete_relation_data,
26+ log):
27 configs = MagicMock()
28 configs.complete_contexts.return_value = ['shared-db', 'amqp']
29 required_interfaces = {
30@@ -882,11 +885,12 @@
31 status_set.assert_called_with('waiting',
32 "Incomplete relations: identity")
33
34+ @patch.object(openstack, 'juju_log')
35 @patch('charmhelpers.contrib.openstack.utils.incomplete_relation_data',
36 return_value={'identity': {'identity-service': {'related': False}}})
37 @patch('charmhelpers.contrib.openstack.utils.status_set')
38 def test_set_os_workload_status_absent(self, status_set,
39- incomplete_relation_data):
40+ incomplete_relation_data, log):
41 configs = MagicMock()
42 configs.complete_contexts.return_value = ['shared-db', 'amqp']
43 required_interfaces = {
44@@ -898,6 +902,7 @@
45 status_set.assert_called_with('blocked',
46 'Missing relations: identity')
47
48+ @patch.object(openstack, 'juju_log')
49 @patch('charmhelpers.contrib.openstack.utils.hook_name',
50 return_value='identity-service-relation-broken')
51 @patch('charmhelpers.contrib.openstack.utils.incomplete_relation_data',
52@@ -905,7 +910,7 @@
53 @patch('charmhelpers.contrib.openstack.utils.status_set')
54 def test_set_os_workload_status_related_broken(self, status_set,
55 incomplete_relation_data,
56- hook_name):
57+ hook_name, log):
58 configs = MagicMock()
59 configs.complete_contexts.return_value = ['shared-db', 'amqp']
60 required_interfaces = {
61@@ -917,6 +922,7 @@
62 status_set.assert_called_with('blocked',
63 "Missing relations: identity")
64
65+ @patch.object(openstack, 'juju_log')
66 @patch('charmhelpers.contrib.openstack.utils.incomplete_relation_data',
67 return_value={'identity':
68 {'identity-service': {'related': True}},
69@@ -929,7 +935,8 @@
70 {'shared-db': {'related': False}}
71 })
72 @patch('charmhelpers.contrib.openstack.utils.status_set')
73- def test_set_os_workload_status_mixed(self, status_set, incomplete_relation_data):
74+ def test_set_os_workload_status_mixed(self, status_set, incomplete_relation_data,
75+ log):
76 configs = MagicMock()
77 configs.complete_contexts.return_value = ['shared-db', 'amqp']
78 required_interfaces = {
79@@ -938,17 +945,24 @@
80 'identity': ['identity-service']}
81
82 openstack.set_os_workload_status(configs, required_interfaces)
83- status_set.assert_called_with('blocked',
84- "Missing relations: database; "
85- "incomplete relations: message, "
86- "identity")
87-
88+
89+ args = status_set.call_args
90+ actual_parm1 = args[0][0]
91+ actual_parm2 = args[0][1]
92+ expected1 = ("Missing relations: database; incomplete relations: "
93+ "identity, message")
94+ expected2 = ("Missing relations: database; incomplete relations: "
95+ "message, identity")
96+ self.assertTrue(actual_parm1 == 'blocked')
97+ self.assertTrue(actual_parm2 == expected1 or actual_parm2 == expected2)
98+
99+ @patch.object(openstack, 'juju_log')
100 @patch.object(openstack, 'action_set')
101 @patch.object(openstack, 'action_fail')
102 @patch.object(openstack, 'openstack_upgrade_available')
103 @patch('charmhelpers.contrib.openstack.utils.config')
104 def test_openstack_upgrade(self, config, openstack_upgrade_available,
105- action_fail, action_set):
106+ action_fail, action_set, log):
107 def do_openstack_upgrade(configs):
108 pass
109
110@@ -966,12 +980,13 @@
111 action_set.assert_called_with({'outcome': msg})
112 self.assertFalse(action_fail.called)
113
114+ @patch.object(openstack, 'juju_log')
115 @patch.object(openstack, 'action_set')
116 @patch.object(openstack, 'action_fail')
117 @patch.object(openstack, 'openstack_upgrade_available')
118 @patch('charmhelpers.contrib.openstack.utils.config')
119 def test_openstack_upgrade_git(self, config, openstack_upgrade_available,
120- action_fail, action_set):
121+ action_fail, action_set, log):
122 def do_openstack_upgrade(configs):
123 pass
124
125@@ -989,13 +1004,14 @@
126 action_set.assert_called_with({'outcome': msg})
127 self.assertFalse(action_fail.called)
128
129+ @patch.object(openstack, 'juju_log')
130 @patch.object(openstack, 'action_set')
131 @patch.object(openstack, 'action_fail')
132 @patch.object(openstack, 'openstack_upgrade_available')
133 @patch('charmhelpers.contrib.openstack.utils.config')
134 def test_openstack_upgrade_not_avail(self, config,
135 openstack_upgrade_available,
136- action_fail, action_set):
137+ action_fail, action_set, log):
138 def do_openstack_upgrade(configs):
139 pass
140
141@@ -1013,13 +1029,14 @@
142 action_set.assert_called_with({'outcome': msg})
143 self.assertFalse(action_fail.called)
144
145+ @patch.object(openstack, 'juju_log')
146 @patch.object(openstack, 'action_set')
147 @patch.object(openstack, 'action_fail')
148 @patch.object(openstack, 'openstack_upgrade_available')
149 @patch('charmhelpers.contrib.openstack.utils.config')
150 def test_openstack_upgrade_config_false(self, config,
151 openstack_upgrade_available,
152- action_fail, action_set):
153+ action_fail, action_set, log):
154 def do_openstack_upgrade(configs):
155 pass
156
157@@ -1037,6 +1054,7 @@
158 action_set.assert_called_with({'outcome': msg})
159 self.assertFalse(action_fail.called)
160
161+ @patch.object(openstack, 'juju_log')
162 @patch.object(openstack, 'action_set')
163 @patch.object(openstack, 'action_fail')
164 @patch.object(openstack, 'openstack_upgrade_available')
165@@ -1044,7 +1062,7 @@
166 @patch('charmhelpers.contrib.openstack.utils.config')
167 def test_openstack_upgrade_traceback(self, config, traceback,
168 openstack_upgrade_available,
169- action_fail, action_set):
170+ action_fail, action_set, log):
171 def do_openstack_upgrade(configs):
172 oops() # noqa
173

Subscribers

People subscribed via source and target branches