MCPcopy Create free account
hub / github.com/DeepL/deepl-python / test_translate_document_string

Function test_translate_document_string

tests/test_translate_document.py:264–287  ·  view source on GitHub ↗
(translator, server)

Source from the content-addressed store, hash-verified

262
263
264def test_translate_document_string(translator, server):
265 input_string = example_text["EN"]
266 handle = translator.translate_document_upload(
267 input_string,
268 source_lang="EN",
269 target_lang="DE",
270 filename="test.txt",
271 )
272
273 status = translator.translate_document_get_status(handle)
274 while status.ok and not status.done:
275 status = translator.translate_document_get_status(handle)
276 time.sleep(status.seconds_remaining or 1)
277
278 assert status.ok
279 response = translator.translate_document_download(handle)
280 try:
281 output = bytes()
282 for chunk in response.iter_content(chunk_size=128):
283 output += chunk
284 output_string = output.decode()
285 assert output_string == example_text["DE"]
286 finally:
287 response.close()
288
289
290@needs_mock_server

Callers

nothing calls this directly

Calls 4

closeMethod · 0.45

Tested by

no test coverage detected