Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc translator] adding tests #17511

Merged
merged 44 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8773e18
[tests][sync] test supported formats
Mar 23, 2021
136e013
[tests][sync] test translation
Mar 23, 2021
5b6bc5a
[tests] comeplete the supported formats test
Mar 24, 2021
65a4ef5
[tests] translation test
Mar 24, 2021
55cf88f
[tests] translation -> single source multiple target
Mar 24, 2021
6e729b0
[test] translation -> multiple sources single targets
Mar 24, 2021
927d456
[test] translation -> prefix and suffix
Mar 24, 2021
62fcd19
[test] translation -> list all doc statuses
Mar 24, 2021
c8d7385
[test] updated tests to create their own containers
Mar 24, 2021
ca39f2e
[tests] update base test functions to support offline tests
Mar 24, 2021
bccfba8
[test] adding more tests
Mar 25, 2021
3aca550
[tests] status tests
Mar 25, 2021
a09c635
[tests] list statuses
Mar 25, 2021
7f0537f
[tests] list submitted jobs
Mar 25, 2021
fff22b2
[tests] doc status
Mar 25, 2021
6dad2f2
[tests] update paging in list all statuses
Mar 25, 2021
82bd4ac
[tests] some refactoring
Mar 25, 2021
e5d81be
[tests] added meaningful assertions + method refactoring
Mar 25, 2021
96b9182
[test] cancel job
Mar 25, 2021
df8bab4
[tests] refactor helper functions
Mar 25, 2021
d6e3bf1
[tests] added async tests
Mar 26, 2021
9e2844b
[tests] skip some tests (functionality is hidden for now)
Mar 26, 2021
c75debf
[tests][pr reviews] correct silly mistake -> calling function with ar…
Mar 27, 2021
789010d
[test] lazy fix -> sample trsnaltion jobs -> wait until done for stat…
Mar 27, 2021
d13c578
[test] some bugs
Mar 27, 2021
011ebe9
[tests] fix gettting first item if async iterator
Mar 27, 2021
f2398c5
[tests] fix cancelled job status propagation
Mar 27, 2021
f53e925
[tests] fix iterator len issue in sync client
Mar 29, 2021
9b4fc39
[tests] fix 'self' keyword used unnecessarily
Mar 29, 2021
756e719
[test] fix get length of async iterator
Mar 29, 2021
8ad8f56
[tests] update tests after actually running them
Mar 29, 2021
eb9c479
[tests] sync client updates
Mar 29, 2021
eaf8abb
[tests] add sync client test recordings
Mar 29, 2021
fa7f0a9
[tests] fixed async client tests
Mar 30, 2021
d16498f
[tests] adding async recordings
Mar 30, 2021
74fbaa0
[tests] adding conftest.py for py2 async tests
Mar 30, 2021
0d985c8
[tests] update recordings
Mar 30, 2021
7fbf545
[tests] pr reviews
Mar 30, 2021
a428819
[tests] created AsyncDocumentTranslationTest for python 3
Mar 30, 2021
7eac34b
[tests] setting polling interval to zero when running recorded tests
Mar 31, 2021
3888faf
[tests] updated polling interval for wait_until_done method in client
Mar 31, 2021
472a51b
[tests] updating recorded tests
Mar 31, 2021
9c9b768
[tests] updated records -> downgrade azure core bug
Mar 31, 2021
f1e8792
[tests] fixing linting errors
Mar 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def callback(raw_response):
initial_response=pipeline_response,
deserialization_callback=callback,
polling_method=LROBasePolling(
timeout=30,
timeout=self._client._config.polling_interval, # pylint: disable=protected-access
lro_algorithms=[TranslationPolling()],
**kwargs
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def callback(raw_response):
initial_response=pipeline_response,
deserialization_callback=callback,
polling_method=AsyncLROBasePolling(
timeout=30,
timeout=self._client._config.polling_interval, # pylint: disable=protected-access
lro_algorithms=[TranslationPolling()],
**kwargs
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# coding=utf-8
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from testcase import DocumentTranslationTest
from azure.ai.documenttranslation import DocumentTranslationInput, TranslationTarget

class AsyncDocumentTranslationTest(DocumentTranslationTest):

def __init__(self, method_name):
super(AsyncDocumentTranslationTest, self).__init__(method_name)

async def _submit_and_validate_translation_job_async(self, async_client, translation_inputs, total_docs_count):
# submit job
job_details = await async_client.create_translation_job(translation_inputs)
self.assertIsNotNone(job_details.id)
# wait for result
job_details = await async_client.wait_until_done(job_details.id)
# validate
self._validate_translation_job(job_details=job_details, status='Succeeded', total=total_docs_count, succeeded=total_docs_count)

return job_details.id

# client helpers
async def _create_and_submit_sample_translation_jobs_async(self, async_client, jobs_count):
result_job_ids = []
for i in range(jobs_count):
# prepare containers and test data
'''
# WARNING!!
TOTAL_DOC_COUNT_IN_JOB = 1
if you plan to create more docs in the job,
please update this variable TOTAL_DOC_COUNT_IN_JOB in respective test

# note
since we're only testing the client library
we can use sync container calls in here
no need for async container clients!
'''
blob_data = b'This is some text'
source_container_sas_url = self.create_source_container(data=blob_data)
target_container_sas_url = self.create_target_container()

# prepare translation inputs
translation_inputs = [
DocumentTranslationInput(
source_url=source_container_sas_url,
targets=[
TranslationTarget(
target_url=target_container_sas_url,
language_code="es"
)
]
)
]

# submit multiple jobs
job_details = await async_client.create_translation_job(translation_inputs)
self.assertIsNotNone(job_details.id)
await async_client.wait_until_done(job_details.id)
result_job_ids.append(job_details.id)

return result_job_ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# coding: utf-8
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

import sys

# Ignore async tests for Python < 3.5
collect_ignore_glob = []
if sys.version_info < (3, 5):
collect_ignore_glob.append("*_async.py")
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def create_resource(self, name, **kwargs):
doctranslation_test_endpoint = kwargs.get("documenttranslation_test_endpoint")
doctranslation_test_api_key = kwargs.get("documenttranslation_test_api_key")

# set polling interval to 0 for recorded tests
if not self.is_live:
self.client_kwargs["polling_interval"] = 0

client = self.client_cls(
doctranslation_test_endpoint,
Expand Down
Loading