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

[translation] add continuation token tests #19105

Merged
merged 3 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -39,6 +39,9 @@ def create_resource(self, name, **kwargs):
# set polling interval to 0 for recorded tests
if not self.is_live:
self.client_kwargs["polling_interval"] = 0
else:
# default is 30s, but our tests translate very small docs so this helps speed up live testing
self.client_kwargs["polling_interval"] = 5

client = self.client_cls(
doctranslation_test_endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,20 @@ def test_overloaded_bad_input(self, client):

with pytest.raises(ValueError):
client.begin_translation(inputs="container")

@pytest.mark.live_test_only
@DocumentTranslationPreparer()
@DocumentTranslationClientPreparer()
def test_translation_continuation_token(self, client):
source_container_sas_url = self.create_source_container(data=Document(data=b'hello world'))
target_container_sas_url = self.create_target_container()

initial_poller = client.begin_translation(source_container_sas_url, target_container_sas_url, "es")
cont_token = initial_poller.continuation_token()

poller = client.begin_translation(None, continuation_token=cont_token)
result = poller.result()
maririos marked this conversation as resolved.
Show resolved Hide resolved
self._validate_translation_metadata(poller, status="Succeeded", total=1, succeeded=1)
for doc in result:
self._validate_doc_status(doc, target_language="es")
initial_poller.wait() # necessary so azure-devtools doesn't throw assertion error
maririos marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,20 @@ async def test_overloaded_bad_input(self, client):

with pytest.raises(ValueError):
await client.begin_translation(inputs="container")

@pytest.mark.live_test_only
@DocumentTranslationPreparer()
@DocumentTranslationClientPreparer()
async def test_translation_continuation_token(self, client):
source_container_sas_url = self.create_source_container(data=Document(data=b'hello world'))
target_container_sas_url = self.create_target_container()

initial_poller = await client.begin_translation(source_container_sas_url, target_container_sas_url, "es")
cont_token = initial_poller.continuation_token()

poller = await client.begin_translation(None, continuation_token=cont_token)
result = await poller.result()
self._validate_translation_metadata(poller, status="Succeeded", total=1, succeeded=1)
async for doc in result:
self._validate_doc_status(doc, target_language="es")
await initial_poller.wait() # necessary so azure-devtools doesn't throw assertion error