From c3c3f45ae92e502100c9af466727e9b2fb9017b1 Mon Sep 17 00:00:00 2001 From: kissiel Date: Thu, 26 Oct 2023 14:45:24 +0200 Subject: [PATCH] fix resultbuilder being None on autoresume (BugFix) (#797) fix resultbuilder being None on autoresume Signed-off-by: Maciej Kisielewski --- .../plainbox/impl/session/remote_assistant.py | 2 +- .../impl/session/test_remote_assistant.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/checkbox-ng/plainbox/impl/session/remote_assistant.py b/checkbox-ng/plainbox/impl/session/remote_assistant.py index e5a4acf82..34dd7f51a 100644 --- a/checkbox-ng/plainbox/impl/session/remote_assistant.py +++ b/checkbox-ng/plainbox/impl/session/remote_assistant.py @@ -596,7 +596,7 @@ def finish_job(self, result=None): # it is already determined return if not result: - if not self._be: + if not self._be or not self._be.wait(): # the job is considered done and there's no background # executor, because the job was auto-passed from the session # resume mechanism after a no-return job has been run diff --git a/checkbox-ng/plainbox/impl/session/test_remote_assistant.py b/checkbox-ng/plainbox/impl/session/test_remote_assistant.py index 67c8dd694..f975f9864 100644 --- a/checkbox-ng/plainbox/impl/session/test_remote_assistant.py +++ b/checkbox-ng/plainbox/impl/session/test_remote_assistant.py @@ -84,3 +84,22 @@ def test_no_result_with_be(self): self.assertTrue(self.rsa._be.wait.called) self.assertTrue(self.rsa._be.wait().get_result) self.assertEqual(result, IJobResult.OUTCOME_PASS) + + @mock.patch("plainbox.impl.session.remote_assistant.JobResultBuilder") + def test_no_result_with_be_but_no_builder(self, MockJobResultBuilder): + self.rsa._currently_running_job = "job_id" + mock_job = mock.Mock() + mock_job.plugin = "shell" + self.rsa._be = mock.Mock() + self.rsa._be.wait.return_value = None + mock_builder = MockJobResultBuilder.return_value + mock_builder.get_result.return_value = IJobResult.OUTCOME_PASS + + result = remote_assistant.RemoteSessionAssistant.finish_job(self.rsa) + + self.rsa._sa.use_job_result.assert_called_with("job_id", "pass") + self.assertEqual(result, IJobResult.OUTCOME_PASS) + MockJobResultBuilder.assert_called_with( + outcome=IJobResult.OUTCOME_PASS, + comments="Automatically passed while resuming", + )