Skip to content

Commit

Permalink
[translation] add continuation token tests (Azure#19105)
Browse files Browse the repository at this point in the history
* add continuation token tests

* cont token tests are live only

* add validation checks
  • Loading branch information
kristapratico authored Jun 4, 2021
1 parent 868c933 commit a5bb8e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
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()
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
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

0 comments on commit a5bb8e2

Please sign in to comment.