Skip to content

Commit 580fc7b

Browse files
committed
Mock upload job artifact in test.
1 parent b9e27fb commit 580fc7b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

tests/unitary/default_setup/jobs/test_jobs_dscjob.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ def setup_method(self):
4141

4242
@property
4343
def sample_create_job_response(self):
44-
self.payload[
45-
"lifecycle_state"
46-
] = oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
44+
self.payload["lifecycle_state"] = (
45+
oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
46+
)
4747
self.payload["id"] = "ocid1.datasciencejob.oc1.iad.<unique_ocid>"
4848
return Response(
4949
data=Job(**self.payload), status=None, headers=None, request=None
5050
)
5151

5252
@property
5353
def sample_create_job_response_with_default_display_name(self):
54-
self.payload[
55-
"lifecycle_state"
56-
] = oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
54+
self.payload["lifecycle_state"] = (
55+
oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
56+
)
5757
random.seed(random_seed)
5858
self.payload["display_name"] = utils.get_random_name_for_resource()
5959
return Response(
@@ -62,9 +62,9 @@ def sample_create_job_response_with_default_display_name(self):
6262

6363
@property
6464
def sample_create_job_response_with_default_display_name_with_artifact(self):
65-
self.payload[
66-
"lifecycle_state"
67-
] = oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
65+
self.payload["lifecycle_state"] = (
66+
oci.data_science.models.Job.LIFECYCLE_STATE_ACTIVE
67+
)
6868
random.seed(random_seed)
6969
self.payload["display_name"] = "my_script_name"
7070
return Response(
@@ -155,14 +155,15 @@ def test_create_job_with_default_display_name_with_artifact(
155155
job = DSCJob(artifact=artifact, **self.payload)
156156
with patch.object(
157157
DSCJob, "client", mock_client_with_default_display_name_with_artifact
158+
), patch.object(
159+
OCIModelMixin,
160+
"to_oci_model",
161+
mock_details_with_default_display_name_with_artifact,
162+
), patch.object(
163+
DSCJob, "upload_artifact"
158164
):
159-
with patch.object(
160-
OCIModelMixin,
161-
"to_oci_model",
162-
mock_details_with_default_display_name_with_artifact,
163-
):
164-
job.create()
165-
assert job.display_name == os.path.basename(str(artifact)).split(".")[0]
165+
job.create()
166+
assert job.display_name == os.path.basename(str(artifact)).split(".")[0]
166167

167168
@pytest.mark.parametrize(
168169
"test_config_details, expected_result",

0 commit comments

Comments
 (0)