Merge lp:~sylvain-pineau/checkbox/fix-python3.5-unittest into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: no longer in the source branch.
Merged at revision: 3966
Proposed branch: lp:~sylvain-pineau/checkbox/fix-python3.5-unittest
Merge into: lp:checkbox
Diff against target: 258 lines (+53/-37)
3 files modified
plainbox/plainbox/impl/secure/providers/test_v1.py (+2/-2)
plainbox/plainbox/impl/session/test_resume.py (+37/-25)
plainbox/plainbox/impl/session/test_suspend.py (+14/-10)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/fix-python3.5-unittest
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+269486@code.launchpad.net

Description of the change

Fix the suspend/resume unit tests after replacing the unittest CamelCase methods names with their underscore versions.

To post a comment you must log in.
3963. By Zygmunt Krynicki

"automatic merge of lp:~zyga/checkbox/fix-developer-decorators/ by tarmac [r=kissiel][bug=][author=zyga]"

3964. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/session-assistant-improvements/ by tarmac [r=zyga][bug=][author=kissiel]"

3965. By Maciej Kisielewski

"automatic merge of lp:~kissiel/checkbox/session-assistant-improvements/ by tarmac [r=zyga][bug=][author=kissiel]"

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Let's land this and iterate.

review: Approve
3966. By Sylvain Pineau

"automatic merge of lp:~sylvain-pineau/checkbox/fix-python3.5-unittest/ by tarmac [r=zyga][bug=][author=sylvain-pineau]"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/secure/providers/test_v1.py'
2--- plainbox/plainbox/impl/secure/providers/test_v1.py 2015-08-03 09:25:27 +0000
3+++ plainbox/plainbox/impl/secure/providers/test_v1.py 2015-08-28 10:02:28 +0000
4@@ -98,7 +98,7 @@
5 def test_existing_directories_work(self, mock_isdir):
6 mock_isdir.return_value = True
7 self.assertEqual(self.validator(self.variable, self._PATH), None)
8- mock_isdir.assertCalledWith(self._PATH)
9+ mock_isdir.assert_called_with(self._PATH)
10
11 @mock.patch('os.path.isdir')
12 def test_missing_directories_dont(self, mock_isdir):
13@@ -106,7 +106,7 @@
14 self.assertEqual(
15 self.validator(self.variable, self._PATH),
16 "no such directory")
17- mock_isdir.assertCalledWith(self._PATH)
18+ mock_isdir.assert_called_with(self._PATH)
19
20
21 class AbsolutePathValidatorTests(TestCase):
22
23=== modified file 'plainbox/plainbox/impl/session/test_resume.py'
24--- plainbox/plainbox/impl/session/test_resume.py 2015-08-24 20:10:03 +0000
25+++ plainbox/plainbox/impl/session/test_resume.py 2015-08-28 10:02:28 +0000
26@@ -126,7 +126,7 @@
27 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
28 b'},"results":{}},"version":1}')
29 SessionResumeHelper([], None, None).resume(data)
30- mocked_helper1.resume_json.assertCalledOnce()
31+ mocked_helper1.resume_json.assert_called_once()
32
33 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper2')
34 def test_resume_dispatch_v2(self, mocked_helper2):
35@@ -135,7 +135,7 @@
36 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
37 b'},"results":{}},"version":2}')
38 SessionResumeHelper([], None, None).resume(data)
39- mocked_helper2.resume_json.assertCalledOnce()
40+ mocked_helper2.resume_json.assert_called_once()
41
42 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper3')
43 def test_resume_dispatch_v3(self, mocked_helper3):
44@@ -145,7 +145,7 @@
45 b'"running_job_name":null,"title":null'
46 b'},"results":{}},"version":3}')
47 SessionResumeHelper([], None, None).resume(data)
48- mocked_helper3.resume_json.assertCalledOnce()
49+ mocked_helper3.resume_json.assert_called_once()
50
51 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper4')
52 def test_resume_dispatch_v4(self, mocked_helper4):
53@@ -155,7 +155,7 @@
54 b'"running_job_name":null,"title":null'
55 b'},"results":{}},"version":4}')
56 SessionResumeHelper([], None, None).resume(data)
57- mocked_helper4.resume_json.assertCalledOnce()
58+ mocked_helper4.resume_json.assert_called_once()
59
60 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper5')
61 def test_resume_dispatch_v5(self, mocked_helper5):
62@@ -165,7 +165,7 @@
63 b'"running_job_name":null,"title":null'
64 b'},"results":{}},"version":5}')
65 SessionResumeHelper([], None, None).resume(data)
66- mocked_helper5.resume_json.assertCalledOnce()
67+ mocked_helper5.resume_json.assert_called_once()
68
69 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper6')
70 def test_resume_dispatch_v6(self, mocked_helper6):
71@@ -175,7 +175,7 @@
72 b'"running_job_name":null,"title":null'
73 b'},"results":{}},"version":6}')
74 SessionResumeHelper([], None, None).resume(data)
75- mocked_helper6.resume_json.assertCalledOnce()
76+ mocked_helper6.resume_json.assert_called_once()
77
78 def test_resume_dispatch_v7(self):
79 data = gzip.compress(
80@@ -194,7 +194,7 @@
81 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
82 b'},"results":{}},"version":1}')
83 SessionPeekHelper().peek(data)
84- mocked_helper1.resume_json.assertCalledOnce()
85+ mocked_helper1.resume_json.assert_called_once()
86
87 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper2')
88 def test_peek_dispatch_v2(self, mocked_helper2):
89@@ -203,7 +203,7 @@
90 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
91 b'},"results":{}},"version":2}')
92 SessionPeekHelper().peek(data)
93- mocked_helper2.resume_json.assertCalledOnce()
94+ mocked_helper2.resume_json.assert_called_once()
95
96 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper3')
97 def test_peek_dispatch_v3(self, mocked_helper3):
98@@ -212,7 +212,7 @@
99 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
100 b'},"results":{}},"version":3}')
101 SessionPeekHelper().peek(data)
102- mocked_helper3.resume_json.assertCalledOnce()
103+ mocked_helper3.resume_json.assert_called_once()
104
105 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper4')
106 def test_peek_dispatch_v4(self, mocked_helper4):
107@@ -221,7 +221,7 @@
108 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
109 b'},"results":{}},"version":4}')
110 SessionPeekHelper().peek(data)
111- mocked_helper4.resume_json.assertCalledOnce()
112+ mocked_helper4.resume_json.assert_called_once()
113
114 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper5')
115 def test_peek_dispatch_v5(self, mocked_helper5):
116@@ -230,7 +230,7 @@
117 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
118 b'},"results":{}},"version":5}')
119 SessionPeekHelper().peek(data)
120- mocked_helper5.resume_json.assertCalledOnce()
121+ mocked_helper5.resume_json.assert_called_once()
122
123 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper6')
124 def test_peek_dispatch_v6(self, mocked_helper6):
125@@ -239,7 +239,7 @@
126 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
127 b'},"results":{}},"version":6}')
128 SessionPeekHelper().peek(data)
129- mocked_helper6.resume_json.assertCalledOnce()
130+ mocked_helper6.resume_json.assert_called_once()
131
132 class SessionResumeTests(TestCase):
133
134@@ -430,8 +430,8 @@
135 """
136 with mock.patch.object(self.helper, attribute='_build_SessionState'):
137 self.helper._build_SessionState(self.session_repr)
138- self.helper._build_SessionState.assertCalledOnceWith(
139- self.session_repr, None)
140+ self.helper._build_SessionState.assert_called_once_with(
141+ self.session_repr)
142
143 def test_calls_restore_SessionState_jobs_and_results(self):
144 """
145@@ -439,11 +439,14 @@
146 _build_SessionState().
147 """
148 mpo = mock.patch.object
149- with mpo(self.helper, '_build_SessionState'), \
150- mpo(self.helper, '_restore_SessionState_jobs_and_results'):
151+ with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
152+ mpo(self.helper, '_restore_SessionState_metadata'), \
153+ mpo(self.helper, '_restore_SessionState_job_list'), \
154+ mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
155+ mpo(self.helper, '_restore_SessionState_desired_job_list'):
156 session = self.helper._build_SessionState(self.session_repr)
157 self.helper._restore_SessionState_jobs_and_results. \
158- assertCalledOnceWith(session, self.session_repr)
159+ assert_called_once_with(session, self.session_repr)
160
161 def test_calls_restore_SessionState_metadata(self):
162 """
163@@ -451,11 +454,14 @@
164 _build_SessionState().
165 """
166 mpo = mock.patch.object
167- with mpo(self.helper, '_build_SessionState'), \
168- mpo(self.helper, '_restore_SessionState_metadata'):
169+ with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
170+ mpo(self.helper, '_restore_SessionState_metadata'), \
171+ mpo(self.helper, '_restore_SessionState_job_list'), \
172+ mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
173+ mpo(self.helper, '_restore_SessionState_desired_job_list'):
174 session = self.helper._build_SessionState(self.session_repr)
175 self.helper._restore_SessionState_metadata. \
176- assertCalledOnceWith(session, self.session_repr)
177+ assert_called_once_with(session.metadata, self.session_repr)
178
179 def test_calls_restore_SessionState_desired_job_list(self):
180 """
181@@ -463,11 +469,14 @@
182 _build_SessionState().
183 """
184 mpo = mock.patch.object
185- with mpo(self.helper, '_build_SessionState'), \
186+ with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
187+ mpo(self.helper, '_restore_SessionState_metadata'), \
188+ mpo(self.helper, '_restore_SessionState_job_list'), \
189+ mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
190 mpo(self.helper, '_restore_SessionState_desired_job_list'):
191 session = self.helper._build_SessionState(self.session_repr)
192 self.helper._restore_SessionState_desired_job_list. \
193- assertCalledOnceWith(session, self.session_repr)
194+ assert_called_once_with(session, self.session_repr)
195
196 def test_calls_restore_SessionState_job_list(self):
197 """
198@@ -475,10 +484,13 @@
199 _build_SessionState().
200 """
201 mpo = mock.patch.object
202- with mpo(self.helper, '_build_SessionState'), \
203- mpo(self.helper, '_restore_SessionState_job_list'):
204+ with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
205+ mpo(self.helper, '_restore_SessionState_metadata'), \
206+ mpo(self.helper, '_restore_SessionState_job_list'), \
207+ mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
208+ mpo(self.helper, '_restore_SessionState_desired_job_list'):
209 session = self.helper._build_SessionState(self.session_repr)
210- self.helper._restore_SessionState_job_list.assertCalledOnceWith(
211+ self.helper._restore_SessionState_job_list.assert_called_once_with(
212 session, self.session_repr)
213
214
215
216=== modified file 'plainbox/plainbox/impl/session/test_suspend.py'
217--- plainbox/plainbox/impl/session/test_suspend.py 2015-08-20 11:17:46 +0000
218+++ plainbox/plainbox/impl/session/test_suspend.py 2015-08-28 10:02:28 +0000
219@@ -217,25 +217,29 @@
220 data = self.helper._repr_IOLogRecord(record)
221 self.assertEqual(data, [0.0, "stdout", "YmluYXJ5IGRhdGE="])
222
223- @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')
224- def test_repr_JobResult_with_MemoryJobResult(self, mocked_helper):
225+ def test_repr_JobResult_with_MemoryJobResult(self):
226 """
227 verify that _repr_JobResult() called with MemoryJobResult
228 calls _repr_MemoryJobResult
229 """
230- result = MemoryJobResult({})
231- self.helper._repr_JobResult(result, self.session_dir)
232- mocked_helper._repr_MemoryJobResult.assertCalledOnceWith(result)
233+ mpo = mock.patch.object
234+ with mpo(self.helper, '_repr_MemoryJobResult'):
235+ result = MemoryJobResult({})
236+ self.helper._repr_JobResult(result, self.session_dir)
237+ self.helper._repr_MemoryJobResult.assert_called_once_with(
238+ result, None)
239
240- @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')
241- def test_repr_JobResult_with_DiskJobResult(self, mocked_helper):
242+ def test_repr_JobResult_with_DiskJobResult(self):
243 """
244 verify that _repr_JobResult() called with DiskJobResult
245 calls _repr_DiskJobResult
246 """
247- result = DiskJobResult({})
248- self.helper._repr_JobResult(result, self.session_dir)
249- mocked_helper._repr_DiskJobResult.assertCalledOnceWith(result)
250+ mpo = mock.patch.object
251+ with mpo(self.helper, '_repr_DiskJobResult'):
252+ result = DiskJobResult({})
253+ self.helper._repr_JobResult(result, self.session_dir)
254+ self.helper._repr_DiskJobResult.assert_called_once_with(
255+ result, None)
256
257 def test_repr_JobResult_with_junk(self):
258 """

Subscribers

People subscribed via source and target branches