Skip to content

Commit 7c27724

Browse files
committed
Fixed unit test.
1 parent c350ba7 commit 7c27724

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

tests/unitary/with_extras/opctl/test_opctl_dataflow_backend.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import pytest
1313
import yaml
14+
from ads.jobs.builders.infrastructure.dataflow import DataFlowRun
1415

1516
from ads.opctl.backend.ads_dataflow import DataFlowBackend
1617

@@ -87,6 +88,23 @@ def test_dataflow_run(self, file_upload, job_run, job_create):
8788
False,
8889
)
8990

91+
@patch(
92+
"ads.opctl.backend.ads_dataflow.DataFlowRun.watch",
93+
return_value=DataFlowRun(),
94+
)
95+
@patch(
96+
"ads.opctl.backend.ads_dataflow.DataFlowRun.from_ocid",
97+
return_value=DataFlowRun(),
98+
)
99+
def test_watch(self, mock_from_ocid, mock_watch):
100+
config = self.config
101+
config["execution"]["run_id"] = "test_dataflow_run_id"
102+
config["execution"]["interval"] = 10
103+
backend = DataFlowBackend(config)
104+
backend.watch()
105+
mock_from_ocid.assert_called_with("test_dataflow_run_id")
106+
mock_watch.assert_called_with(interval=10)
107+
90108
@pytest.mark.parametrize(
91109
"runtime_type",
92110
["dataFlow", "dataFlowNotebook"],

tests/unitary/with_extras/opctl/test_opctl_ml_job_backend.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ def test_run_with_image(self, rt, job_run, job_create):
109109
job_create.assert_called()
110110
job_run.assert_called()
111111

112+
@patch(
113+
"ads.opctl.backend.ads_ml_job.DataScienceJobRun.watch",
114+
return_value=DataScienceJobRun(),
115+
)
116+
@patch(
117+
"ads.opctl.backend.ads_ml_job.DataScienceJobRun.from_ocid",
118+
return_value=DataScienceJobRun(),
119+
)
120+
def test_watch(self, mock_from_ocid, mock_watch):
121+
config = self.config
122+
config["execution"]["run_id"] = "test_job_run_id"
123+
config["execution"]["interval"] = 10
124+
config["execution"]["wait"] = 15
125+
backend = MLJobBackend(config)
126+
backend.watch()
127+
mock_from_ocid.assert_called_with("test_job_run_id")
128+
mock_watch.assert_called_with(interval=10, wait=15)
129+
112130
@pytest.mark.parametrize(
113131
"runtime_type",
114132
["container", "script", "python", "notebook", "gitPython"],

tests/unitary/with_extras/opctl/test_opctl_ml_pipeline_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,11 @@ def test_watch(self, mock_from_ocid, mock_watch):
129129
config = self.config
130130
config["execution"]["run_id"] = "test_pipeline_run_id"
131131
config["execution"]["log_type"] = "custom_log"
132+
config["execution"]["interval"] = 10
132133
backend = PipelineBackend(config)
133134
backend.watch()
134135
mock_from_ocid.assert_called_with("test_pipeline_run_id")
135-
mock_watch.assert_called_with(log_type="custom_log")
136+
mock_watch.assert_called_with(interval=10, log_type="custom_log")
136137

137138
@pytest.mark.parametrize(
138139
"runtime_type",

0 commit comments

Comments
 (0)