Skip to content

Commit

Permalink
fix resultbuilder being None on autoresume (BugFix) (#797)
Browse files Browse the repository at this point in the history
fix resultbuilder being None on autoresume

Signed-off-by: Maciej Kisielewski <[email protected]>
  • Loading branch information
kissiel authored Oct 26, 2023
1 parent 40d2f3f commit c3c3f45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion checkbox-ng/plainbox/impl/session/remote_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions checkbox-ng/plainbox/impl/session/test_remote_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

0 comments on commit c3c3f45

Please sign in to comment.