Skip to content

Commit

Permalink
Update unit test to take mandatory jobs into account
Browse files Browse the repository at this point in the history
  • Loading branch information
pieqq committed Nov 15, 2024
1 parent 7087c12 commit 2fcb7da
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions checkbox-ng/plainbox/impl/session/test_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,26 @@ def test_use_alternate_selection(self, mock_get_providers):

job1_id = "com.canonical.certification::job_1"
job2_id = "com.canonical.certification::job_2"
job3_id = "com.canonical.certification::job_3"
job1 = JobDefinition({"id": job1_id})
job2 = JobDefinition({"id": job2_id})
job3 = JobDefinition({"id": job3_id})

self_mock._metadata.rejected_jobs = ["already-rejected-job"]
self_mock.get_static_todo_list.return_value = [job1_id, job2_id]
self_mock._context.get_unit.side_effect = [job1, job2]
selection = [job1_id]
self_mock.get_mandatory_jobs.return_value = [job1_id]
self_mock.get_static_todo_list.return_value = [
job1_id,
job2_id,
job3_id,
]
self_mock._context.get_unit.side_effect = [job2]
selection = [job2_id]

SessionAssistant.use_alternate_selection(self_mock, selection)
self.assertEqual(len(self_mock._metadata.rejected_jobs), 2)
self_mock._context.state.update_desired_job_list.assert_called_with(
[job1]
# job1 is not part of the selection, but it's a mandatory job, so it
# should not be added to the rejected jobs, because it's going to be run.
self.assertEqual(
self_mock._metadata.rejected_jobs,
["already-rejected-job", job3_id],
)
self_mock._context.get_unit.assert_called_once_with(job2_id, "job")

0 comments on commit 2fcb7da

Please sign in to comment.