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
=== modified file 'plainbox/plainbox/impl/secure/providers/test_v1.py'
--- plainbox/plainbox/impl/secure/providers/test_v1.py 2015-08-03 09:25:27 +0000
+++ plainbox/plainbox/impl/secure/providers/test_v1.py 2015-08-28 10:02:28 +0000
@@ -98,7 +98,7 @@
98 def test_existing_directories_work(self, mock_isdir):98 def test_existing_directories_work(self, mock_isdir):
99 mock_isdir.return_value = True99 mock_isdir.return_value = True
100 self.assertEqual(self.validator(self.variable, self._PATH), None)100 self.assertEqual(self.validator(self.variable, self._PATH), None)
101 mock_isdir.assertCalledWith(self._PATH)101 mock_isdir.assert_called_with(self._PATH)
102102
103 @mock.patch('os.path.isdir')103 @mock.patch('os.path.isdir')
104 def test_missing_directories_dont(self, mock_isdir):104 def test_missing_directories_dont(self, mock_isdir):
@@ -106,7 +106,7 @@
106 self.assertEqual(106 self.assertEqual(
107 self.validator(self.variable, self._PATH),107 self.validator(self.variable, self._PATH),
108 "no such directory")108 "no such directory")
109 mock_isdir.assertCalledWith(self._PATH)109 mock_isdir.assert_called_with(self._PATH)
110110
111111
112class AbsolutePathValidatorTests(TestCase):112class AbsolutePathValidatorTests(TestCase):
113113
=== modified file 'plainbox/plainbox/impl/session/test_resume.py'
--- plainbox/plainbox/impl/session/test_resume.py 2015-08-24 20:10:03 +0000
+++ plainbox/plainbox/impl/session/test_resume.py 2015-08-28 10:02:28 +0000
@@ -126,7 +126,7 @@
126 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'126 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
127 b'},"results":{}},"version":1}')127 b'},"results":{}},"version":1}')
128 SessionResumeHelper([], None, None).resume(data)128 SessionResumeHelper([], None, None).resume(data)
129 mocked_helper1.resume_json.assertCalledOnce()129 mocked_helper1.resume_json.assert_called_once()
130130
131 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper2')131 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper2')
132 def test_resume_dispatch_v2(self, mocked_helper2):132 def test_resume_dispatch_v2(self, mocked_helper2):
@@ -135,7 +135,7 @@
135 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'135 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
136 b'},"results":{}},"version":2}')136 b'},"results":{}},"version":2}')
137 SessionResumeHelper([], None, None).resume(data)137 SessionResumeHelper([], None, None).resume(data)
138 mocked_helper2.resume_json.assertCalledOnce()138 mocked_helper2.resume_json.assert_called_once()
139139
140 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper3')140 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper3')
141 def test_resume_dispatch_v3(self, mocked_helper3):141 def test_resume_dispatch_v3(self, mocked_helper3):
@@ -145,7 +145,7 @@
145 b'"running_job_name":null,"title":null'145 b'"running_job_name":null,"title":null'
146 b'},"results":{}},"version":3}')146 b'},"results":{}},"version":3}')
147 SessionResumeHelper([], None, None).resume(data)147 SessionResumeHelper([], None, None).resume(data)
148 mocked_helper3.resume_json.assertCalledOnce()148 mocked_helper3.resume_json.assert_called_once()
149149
150 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper4')150 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper4')
151 def test_resume_dispatch_v4(self, mocked_helper4):151 def test_resume_dispatch_v4(self, mocked_helper4):
@@ -155,7 +155,7 @@
155 b'"running_job_name":null,"title":null'155 b'"running_job_name":null,"title":null'
156 b'},"results":{}},"version":4}')156 b'},"results":{}},"version":4}')
157 SessionResumeHelper([], None, None).resume(data)157 SessionResumeHelper([], None, None).resume(data)
158 mocked_helper4.resume_json.assertCalledOnce()158 mocked_helper4.resume_json.assert_called_once()
159159
160 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper5')160 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper5')
161 def test_resume_dispatch_v5(self, mocked_helper5):161 def test_resume_dispatch_v5(self, mocked_helper5):
@@ -165,7 +165,7 @@
165 b'"running_job_name":null,"title":null'165 b'"running_job_name":null,"title":null'
166 b'},"results":{}},"version":5}')166 b'},"results":{}},"version":5}')
167 SessionResumeHelper([], None, None).resume(data)167 SessionResumeHelper([], None, None).resume(data)
168 mocked_helper5.resume_json.assertCalledOnce()168 mocked_helper5.resume_json.assert_called_once()
169169
170 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper6')170 @mock.patch('plainbox.impl.session.resume.SessionResumeHelper6')
171 def test_resume_dispatch_v6(self, mocked_helper6):171 def test_resume_dispatch_v6(self, mocked_helper6):
@@ -175,7 +175,7 @@
175 b'"running_job_name":null,"title":null'175 b'"running_job_name":null,"title":null'
176 b'},"results":{}},"version":6}')176 b'},"results":{}},"version":6}')
177 SessionResumeHelper([], None, None).resume(data)177 SessionResumeHelper([], None, None).resume(data)
178 mocked_helper6.resume_json.assertCalledOnce()178 mocked_helper6.resume_json.assert_called_once()
179179
180 def test_resume_dispatch_v7(self):180 def test_resume_dispatch_v7(self):
181 data = gzip.compress(181 data = gzip.compress(
@@ -194,7 +194,7 @@
194 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'194 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
195 b'},"results":{}},"version":1}')195 b'},"results":{}},"version":1}')
196 SessionPeekHelper().peek(data)196 SessionPeekHelper().peek(data)
197 mocked_helper1.resume_json.assertCalledOnce()197 mocked_helper1.resume_json.assert_called_once()
198198
199 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper2')199 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper2')
200 def test_peek_dispatch_v2(self, mocked_helper2):200 def test_peek_dispatch_v2(self, mocked_helper2):
@@ -203,7 +203,7 @@
203 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'203 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
204 b'},"results":{}},"version":2}')204 b'},"results":{}},"version":2}')
205 SessionPeekHelper().peek(data)205 SessionPeekHelper().peek(data)
206 mocked_helper2.resume_json.assertCalledOnce()206 mocked_helper2.resume_json.assert_called_once()
207207
208 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper3')208 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper3')
209 def test_peek_dispatch_v3(self, mocked_helper3):209 def test_peek_dispatch_v3(self, mocked_helper3):
@@ -212,7 +212,7 @@
212 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'212 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
213 b'},"results":{}},"version":3}')213 b'},"results":{}},"version":3}')
214 SessionPeekHelper().peek(data)214 SessionPeekHelper().peek(data)
215 mocked_helper3.resume_json.assertCalledOnce()215 mocked_helper3.resume_json.assert_called_once()
216216
217 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper4')217 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper4')
218 def test_peek_dispatch_v4(self, mocked_helper4):218 def test_peek_dispatch_v4(self, mocked_helper4):
@@ -221,7 +221,7 @@
221 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'221 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
222 b'},"results":{}},"version":4}')222 b'},"results":{}},"version":4}')
223 SessionPeekHelper().peek(data)223 SessionPeekHelper().peek(data)
224 mocked_helper4.resume_json.assertCalledOnce()224 mocked_helper4.resume_json.assert_called_once()
225225
226 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper5')226 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper5')
227 def test_peek_dispatch_v5(self, mocked_helper5):227 def test_peek_dispatch_v5(self, mocked_helper5):
@@ -230,7 +230,7 @@
230 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'230 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
231 b'},"results":{}},"version":5}')231 b'},"results":{}},"version":5}')
232 SessionPeekHelper().peek(data)232 SessionPeekHelper().peek(data)
233 mocked_helper5.resume_json.assertCalledOnce()233 mocked_helper5.resume_json.assert_called_once()
234234
235 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper6')235 @mock.patch('plainbox.impl.session.resume.SessionPeekHelper6')
236 def test_peek_dispatch_v6(self, mocked_helper6):236 def test_peek_dispatch_v6(self, mocked_helper6):
@@ -239,7 +239,7 @@
239 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'239 b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
240 b'},"results":{}},"version":6}')240 b'},"results":{}},"version":6}')
241 SessionPeekHelper().peek(data)241 SessionPeekHelper().peek(data)
242 mocked_helper6.resume_json.assertCalledOnce()242 mocked_helper6.resume_json.assert_called_once()
243243
244class SessionResumeTests(TestCase):244class SessionResumeTests(TestCase):
245245
@@ -430,8 +430,8 @@
430 """430 """
431 with mock.patch.object(self.helper, attribute='_build_SessionState'):431 with mock.patch.object(self.helper, attribute='_build_SessionState'):
432 self.helper._build_SessionState(self.session_repr)432 self.helper._build_SessionState(self.session_repr)
433 self.helper._build_SessionState.assertCalledOnceWith(433 self.helper._build_SessionState.assert_called_once_with(
434 self.session_repr, None)434 self.session_repr)
435435
436 def test_calls_restore_SessionState_jobs_and_results(self):436 def test_calls_restore_SessionState_jobs_and_results(self):
437 """437 """
@@ -439,11 +439,14 @@
439 _build_SessionState().439 _build_SessionState().
440 """440 """
441 mpo = mock.patch.object441 mpo = mock.patch.object
442 with mpo(self.helper, '_build_SessionState'), \442 with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
443 mpo(self.helper, '_restore_SessionState_jobs_and_results'):443 mpo(self.helper, '_restore_SessionState_metadata'), \
444 mpo(self.helper, '_restore_SessionState_job_list'), \
445 mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
446 mpo(self.helper, '_restore_SessionState_desired_job_list'):
444 session = self.helper._build_SessionState(self.session_repr)447 session = self.helper._build_SessionState(self.session_repr)
445 self.helper._restore_SessionState_jobs_and_results. \448 self.helper._restore_SessionState_jobs_and_results. \
446 assertCalledOnceWith(session, self.session_repr)449 assert_called_once_with(session, self.session_repr)
447450
448 def test_calls_restore_SessionState_metadata(self):451 def test_calls_restore_SessionState_metadata(self):
449 """452 """
@@ -451,11 +454,14 @@
451 _build_SessionState().454 _build_SessionState().
452 """455 """
453 mpo = mock.patch.object456 mpo = mock.patch.object
454 with mpo(self.helper, '_build_SessionState'), \457 with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
455 mpo(self.helper, '_restore_SessionState_metadata'):458 mpo(self.helper, '_restore_SessionState_metadata'), \
459 mpo(self.helper, '_restore_SessionState_job_list'), \
460 mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
461 mpo(self.helper, '_restore_SessionState_desired_job_list'):
456 session = self.helper._build_SessionState(self.session_repr)462 session = self.helper._build_SessionState(self.session_repr)
457 self.helper._restore_SessionState_metadata. \463 self.helper._restore_SessionState_metadata. \
458 assertCalledOnceWith(session, self.session_repr)464 assert_called_once_with(session.metadata, self.session_repr)
459465
460 def test_calls_restore_SessionState_desired_job_list(self):466 def test_calls_restore_SessionState_desired_job_list(self):
461 """467 """
@@ -463,11 +469,14 @@
463 _build_SessionState().469 _build_SessionState().
464 """470 """
465 mpo = mock.patch.object471 mpo = mock.patch.object
466 with mpo(self.helper, '_build_SessionState'), \472 with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
473 mpo(self.helper, '_restore_SessionState_metadata'), \
474 mpo(self.helper, '_restore_SessionState_job_list'), \
475 mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
467 mpo(self.helper, '_restore_SessionState_desired_job_list'):476 mpo(self.helper, '_restore_SessionState_desired_job_list'):
468 session = self.helper._build_SessionState(self.session_repr)477 session = self.helper._build_SessionState(self.session_repr)
469 self.helper._restore_SessionState_desired_job_list. \478 self.helper._restore_SessionState_desired_job_list. \
470 assertCalledOnceWith(session, self.session_repr)479 assert_called_once_with(session, self.session_repr)
471480
472 def test_calls_restore_SessionState_job_list(self):481 def test_calls_restore_SessionState_job_list(self):
473 """482 """
@@ -475,10 +484,13 @@
475 _build_SessionState().484 _build_SessionState().
476 """485 """
477 mpo = mock.patch.object486 mpo = mock.patch.object
478 with mpo(self.helper, '_build_SessionState'), \487 with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
479 mpo(self.helper, '_restore_SessionState_job_list'):488 mpo(self.helper, '_restore_SessionState_metadata'), \
489 mpo(self.helper, '_restore_SessionState_job_list'), \
490 mpo(self.helper, '_restore_SessionState_mandatory_job_list'), \
491 mpo(self.helper, '_restore_SessionState_desired_job_list'):
480 session = self.helper._build_SessionState(self.session_repr)492 session = self.helper._build_SessionState(self.session_repr)
481 self.helper._restore_SessionState_job_list.assertCalledOnceWith(493 self.helper._restore_SessionState_job_list.assert_called_once_with(
482 session, self.session_repr)494 session, self.session_repr)
483495
484496
485497
=== modified file 'plainbox/plainbox/impl/session/test_suspend.py'
--- plainbox/plainbox/impl/session/test_suspend.py 2015-08-20 11:17:46 +0000
+++ plainbox/plainbox/impl/session/test_suspend.py 2015-08-28 10:02:28 +0000
@@ -217,25 +217,29 @@
217 data = self.helper._repr_IOLogRecord(record)217 data = self.helper._repr_IOLogRecord(record)
218 self.assertEqual(data, [0.0, "stdout", "YmluYXJ5IGRhdGE="])218 self.assertEqual(data, [0.0, "stdout", "YmluYXJ5IGRhdGE="])
219219
220 @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')220 def test_repr_JobResult_with_MemoryJobResult(self):
221 def test_repr_JobResult_with_MemoryJobResult(self, mocked_helper):
222 """221 """
223 verify that _repr_JobResult() called with MemoryJobResult222 verify that _repr_JobResult() called with MemoryJobResult
224 calls _repr_MemoryJobResult223 calls _repr_MemoryJobResult
225 """224 """
226 result = MemoryJobResult({})225 mpo = mock.patch.object
227 self.helper._repr_JobResult(result, self.session_dir)226 with mpo(self.helper, '_repr_MemoryJobResult'):
228 mocked_helper._repr_MemoryJobResult.assertCalledOnceWith(result)227 result = MemoryJobResult({})
228 self.helper._repr_JobResult(result, self.session_dir)
229 self.helper._repr_MemoryJobResult.assert_called_once_with(
230 result, None)
229231
230 @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')232 def test_repr_JobResult_with_DiskJobResult(self):
231 def test_repr_JobResult_with_DiskJobResult(self, mocked_helper):
232 """233 """
233 verify that _repr_JobResult() called with DiskJobResult234 verify that _repr_JobResult() called with DiskJobResult
234 calls _repr_DiskJobResult235 calls _repr_DiskJobResult
235 """236 """
236 result = DiskJobResult({})237 mpo = mock.patch.object
237 self.helper._repr_JobResult(result, self.session_dir)238 with mpo(self.helper, '_repr_DiskJobResult'):
238 mocked_helper._repr_DiskJobResult.assertCalledOnceWith(result)239 result = DiskJobResult({})
240 self.helper._repr_JobResult(result, self.session_dir)
241 self.helper._repr_DiskJobResult.assert_called_once_with(
242 result, None)
239243
240 def test_repr_JobResult_with_junk(self):244 def test_repr_JobResult_with_junk(self):
241 """245 """

Subscribers

People subscribed via source and target branches