Skip to content

Commit 567a408

Browse files
author
Mohamed Shaban
authored
make 'cancel job' tests more robust (Azure#18329)
* updated 'cancel job' tests * fix some errors * updated cancel tests * add recorded tests
1 parent 8b1c366 commit 567a408

File tree

6 files changed

+935
-166
lines changed

6 files changed

+935
-166
lines changed

sdk/translation/azure-ai-translation-document/tests/asynctestcase.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,44 @@ async def _create_and_submit_sample_translation_jobs_async(self, async_client, j
6161
await async_client.wait_until_done(job_details.id)
6262
result_job_ids.append(job_details.id)
6363

64-
return result_job_ids
64+
return result_job_ids
65+
66+
67+
async def _create_translation_job_with_dummy_docs_async(self, async_client, docs_count, **kwargs):
68+
'''
69+
appropriated this method from another PR! #18302
70+
please resolve conflict before merge
71+
keep in mind it's the exact same method
72+
'''
73+
# get input parms
74+
wait_for_job = kwargs.pop('wait', False)
75+
language_code = kwargs.pop('language_code', "es")
76+
77+
# prepare containers and test data
78+
blob_data = Document.create_dummy_docs(docs_count=docs_count)
79+
source_container_sas_url = self.create_source_container(data=blob_data)
80+
target_container_sas_url = self.create_target_container()
81+
82+
# prepare translation inputs
83+
translation_inputs = [
84+
DocumentTranslationInput(
85+
source_url=source_container_sas_url,
86+
targets=[
87+
TranslationTarget(
88+
target_url=target_container_sas_url,
89+
language_code=language_code
90+
)
91+
]
92+
)
93+
]
94+
95+
# submit job
96+
job_details = await async_client.create_translation_job(translation_inputs)
97+
self.assertIsNotNone(job_details.id)
98+
# wait for result
99+
if wait_for_job:
100+
await async_client.wait_until_done(job_details.id)
101+
# validate
102+
self._validate_translation_job(job_details=job_details)
103+
104+
return job_details.id

0 commit comments

Comments
 (0)