Skip to content

Commit 0ad891a

Browse files
committed
Added unit test.
1 parent 326db9b commit 0ad891a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/unitary/default_setup/jobs/test_jobs_base.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ScriptRuntime,
2121
NotebookRuntime,
2222
)
23+
from ads.jobs.builders.infrastructure.dsc_job import DataScienceJobRun
2324
from ads.jobs.builders.infrastructure.dsc_job_runtime import (
2425
CondaRuntimeHandler,
2526
ScriptRuntimeHandler,
@@ -603,3 +604,25 @@ def test_run_details_link_fail(self, mock_extract_region):
603604
test_run_instance = RunInstance()
604605
test_result = test_run_instance.run_details_link
605606
assert test_result == ""
607+
608+
609+
class DataScienceJobMethodTest(DataScienceJobPayloadTest):
610+
611+
@patch("ads.jobs.builders.infrastructure.dsc_job.DataScienceJobRun.cancel")
612+
@patch("ads.jobs.ads_job.Job.run_list")
613+
def test_job_cancel(self, mock_run_list, mock_cancel):
614+
mock_run_list.return_value = [
615+
DataScienceJobRun(
616+
lifecycle_state="CANCELED"
617+
)
618+
] * 3
619+
620+
job = (
621+
Job(name="test")
622+
.with_infrastructure(infrastructure.DataScienceJob())
623+
.with_runtime(ScriptRuntime().with_script(self.SCRIPT_URI))
624+
)
625+
626+
job.cancel()
627+
mock_run_list.assert_called()
628+
mock_cancel.assert_called_with(wait_for_completion=False)

0 commit comments

Comments
 (0)