Description: Replace unittest CamelCase method names with their underscore versions
 Camel case methods are not mock methods we were expecting to call.  More mocks
 were needed in the SessionResumeTests to check that all method calls from
 _build_SessionState() are effectively called once.
Author: Sylvain Pineau <sylvain.pineau@canonical.com>
Origin: upstream, https://code.launchpad.net/~sylvain-pineau/checkbox/fix-python3.5-unittest/+merge/269486 
Forwarded: not-needed
Last-Update: 2015-08-28

--- plainbox-0.22.2.orig/plainbox/impl/secure/providers/test_v1.py
+++ plainbox-0.22.2/plainbox/impl/secure/providers/test_v1.py
@@ -98,7 +98,7 @@ class ExistingDirectoryValidatorTests(Te
     def test_existing_directories_work(self, mock_isdir):
         mock_isdir.return_value = True
         self.assertEqual(self.validator(self.variable, self._PATH), None)
-        mock_isdir.assertCalledWith(self._PATH)
+        mock_isdir.assert_called_with(self._PATH)
 
     @mock.patch('os.path.isdir')
     def test_missing_directories_dont(self, mock_isdir):
@@ -106,7 +106,7 @@ class ExistingDirectoryValidatorTests(Te
         self.assertEqual(
             self.validator(self.variable, self._PATH),
             "no such directory")
-        mock_isdir.assertCalledWith(self._PATH)
+        mock_isdir.assert_called_with(self._PATH)
 
 
 class AbsolutePathValidatorTests(TestCase):
--- plainbox-0.22.2.orig/plainbox/impl/session/test_resume.py
+++ plainbox-0.22.2/plainbox/impl/session/test_resume.py
@@ -124,7 +124,7 @@ class SessionResumeHelperTests(TestCase)
             b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
             b'},"results":{}},"version":1}')
         SessionResumeHelper([], None, None).resume(data)
-        mocked_helper1.resume_json.assertCalledOnce()
+        mocked_helper1.resume_json.assert_called_once()
 
     @mock.patch('plainbox.impl.session.resume.SessionResumeHelper2')
     def test_resume_dispatch_v2(self, mocked_helper2):
@@ -133,7 +133,7 @@ class SessionResumeHelperTests(TestCase)
             b'{"app_blob":null,"flags":[],"running_job_name":null,"title":null'
             b'},"results":{}},"version":2}')
         SessionResumeHelper([], None, None).resume(data)
-        mocked_helper2.resume_json.assertCalledOnce()
+        mocked_helper2.resume_json.assert_called_once()
 
     @mock.patch('plainbox.impl.session.resume.SessionResumeHelper3')
     def test_resume_dispatch_v3(self, mocked_helper3):
@@ -143,7 +143,7 @@ class SessionResumeHelperTests(TestCase)
             b'"running_job_name":null,"title":null'
             b'},"results":{}},"version":3}')
         SessionResumeHelper([], None, None).resume(data)
-        mocked_helper3.resume_json.assertCalledOnce()
+        mocked_helper3.resume_json.assert_called_once()
 
     @mock.patch('plainbox.impl.session.resume.SessionResumeHelper4')
     def test_resume_dispatch_v4(self, mocked_helper4):
@@ -153,7 +153,7 @@ class SessionResumeHelperTests(TestCase)
             b'"running_job_name":null,"title":null'
             b'},"results":{}},"version":4}')
         SessionResumeHelper([], None, None).resume(data)
-        mocked_helper4.resume_json.assertCalledOnce()
+        mocked_helper4.resume_json.assert_called_once()
 
     @mock.patch('plainbox.impl.session.resume.SessionResumeHelper5')
     def test_resume_dispatch_v5(self, mocked_helper5):
@@ -163,7 +163,7 @@ class SessionResumeHelperTests(TestCase)
             b'"running_job_name":null,"title":null'
             b'},"results":{}},"version":5}')
         SessionResumeHelper([], None, None).resume(data)
-        mocked_helper5.resume_json.assertCalledOnce()
+        mocked_helper5.resume_json.assert_called_once()
 
     def test_resume_dispatch_v6(self):
         data = gzip.compress(
@@ -361,8 +361,8 @@ class SessionStateResumeTests(TestCaseWi
         """
         with mock.patch.object(self.helper, attribute='_build_SessionState'):
             self.helper._build_SessionState(self.session_repr)
-            self.helper._build_SessionState.assertCalledOnceWith(
-                self.session_repr, None)
+            self.helper._build_SessionState.assert_called_once_with(
+                self.session_repr)
 
     def test_calls_restore_SessionState_jobs_and_results(self):
         """
@@ -370,11 +370,13 @@ class SessionStateResumeTests(TestCaseWi
         _build_SessionState().
         """
         mpo = mock.patch.object
-        with mpo(self.helper, '_build_SessionState'), \
-                mpo(self.helper, '_restore_SessionState_jobs_and_results'):
+        with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
+                mpo(self.helper, '_restore_SessionState_metadata'), \
+                mpo(self.helper, '_restore_SessionState_job_list'), \
+                mpo(self.helper, '_restore_SessionState_desired_job_list'):
             session = self.helper._build_SessionState(self.session_repr)
             self.helper._restore_SessionState_jobs_and_results. \
-                assertCalledOnceWith(session, self.session_repr)
+                assert_called_once_with(session, self.session_repr)
 
     def test_calls_restore_SessionState_metadata(self):
         """
@@ -382,11 +384,13 @@ class SessionStateResumeTests(TestCaseWi
         _build_SessionState().
         """
         mpo = mock.patch.object
-        with mpo(self.helper, '_build_SessionState'), \
-                mpo(self.helper, '_restore_SessionState_metadata'):
+        with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
+                mpo(self.helper, '_restore_SessionState_metadata'), \
+                mpo(self.helper, '_restore_SessionState_job_list'), \
+                mpo(self.helper, '_restore_SessionState_desired_job_list'):
             session = self.helper._build_SessionState(self.session_repr)
             self.helper._restore_SessionState_metadata. \
-                assertCalledOnceWith(session, self.session_repr)
+                assert_called_once_with(session.metadata, self.session_repr)
 
     def test_calls_restore_SessionState_desired_job_list(self):
         """
@@ -394,11 +398,13 @@ class SessionStateResumeTests(TestCaseWi
         _build_SessionState().
         """
         mpo = mock.patch.object
-        with mpo(self.helper, '_build_SessionState'), \
+        with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
+                mpo(self.helper, '_restore_SessionState_metadata'), \
+                mpo(self.helper, '_restore_SessionState_job_list'), \
                 mpo(self.helper, '_restore_SessionState_desired_job_list'):
             session = self.helper._build_SessionState(self.session_repr)
             self.helper._restore_SessionState_desired_job_list. \
-                assertCalledOnceWith(session, self.session_repr)
+                assert_called_once_with(session, self.session_repr)
 
     def test_calls_restore_SessionState_job_list(self):
         """
@@ -406,10 +412,12 @@ class SessionStateResumeTests(TestCaseWi
         _build_SessionState().
         """
         mpo = mock.patch.object
-        with mpo(self.helper, '_build_SessionState'), \
-                mpo(self.helper, '_restore_SessionState_job_list'):
+        with mpo(self.helper, '_restore_SessionState_jobs_and_results'), \
+                mpo(self.helper, '_restore_SessionState_metadata'), \
+                mpo(self.helper, '_restore_SessionState_job_list'), \
+                mpo(self.helper, '_restore_SessionState_desired_job_list'):
             session = self.helper._build_SessionState(self.session_repr)
-            self.helper._restore_SessionState_job_list.assertCalledOnceWith(
+            self.helper._restore_SessionState_job_list.assert_called_once_with(
                 session, self.session_repr)
 
 
--- plainbox-0.22.2.orig/plainbox/impl/session/test_suspend.py
+++ plainbox-0.22.2/plainbox/impl/session/test_suspend.py
@@ -216,25 +216,29 @@ class SessionSuspendHelper1Tests(TestCas
         data = self.helper._repr_IOLogRecord(record)
         self.assertEqual(data, [0.0, "stdout", "YmluYXJ5IGRhdGE="])
 
-    @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')
-    def test_repr_JobResult_with_MemoryJobResult(self, mocked_helper):
+    def test_repr_JobResult_with_MemoryJobResult(self):
         """
         verify that _repr_JobResult() called with MemoryJobResult
         calls _repr_MemoryJobResult
         """
-        result = MemoryJobResult({})
-        self.helper._repr_JobResult(result, self.session_dir)
-        mocked_helper._repr_MemoryJobResult.assertCalledOnceWith(result)
+        mpo = mock.patch.object
+        with mpo(self.helper, '_repr_MemoryJobResult'):
+            result = MemoryJobResult({})
+            self.helper._repr_JobResult(result, self.session_dir)
+            self.helper._repr_MemoryJobResult.assert_called_once_with(
+                result, None)
 
-    @mock.patch('plainbox.impl.session.suspend.SessionSuspendHelper')
-    def test_repr_JobResult_with_DiskJobResult(self, mocked_helper):
+    def test_repr_JobResult_with_DiskJobResult(self):
         """
         verify that _repr_JobResult() called with DiskJobResult
         calls _repr_DiskJobResult
         """
-        result = DiskJobResult({})
-        self.helper._repr_JobResult(result, self.session_dir)
-        mocked_helper._repr_DiskJobResult.assertCalledOnceWith(result)
+        mpo = mock.patch.object
+        with mpo(self.helper, '_repr_DiskJobResult'):
+            result = DiskJobResult({})
+            self.helper._repr_JobResult(result, self.session_dir)
+            self.helper._repr_DiskJobResult.assert_called_once_with(
+                result, None)
 
     def test_repr_JobResult_with_junk(self):
         """
