(
translator,
example_document_path,
example_document_translation,
output_document_path,
server,
)
| 226 | |
| 227 | @needs_mock_server |
| 228 | def test_translate_document_low_level( |
| 229 | translator, |
| 230 | example_document_path, |
| 231 | example_document_translation, |
| 232 | output_document_path, |
| 233 | server, |
| 234 | ): |
| 235 | # Set a small document queue time to attempt downloading a queued document |
| 236 | server.set_doc_queue_time(100) |
| 237 | |
| 238 | with open(example_document_path, "rb") as infile: |
| 239 | handle = translator.translate_document_upload( |
| 240 | infile, **default_lang_args |
| 241 | ) |
| 242 | status = translator.translate_document_get_status(handle) |
| 243 | assert status.ok and not status.done |
| 244 | |
| 245 | # Test recreating a document handle from id & key |
| 246 | doc_id, doc_key = handle.document_id, handle.document_key |
| 247 | del handle |
| 248 | |
| 249 | handle = deepl.DocumentHandle(doc_id, doc_key) |
| 250 | status = translator.translate_document_get_status(handle) |
| 251 | assert status.ok |
| 252 | |
| 253 | while status.ok and not status.done: |
| 254 | status = translator.translate_document_get_status(handle) |
| 255 | time.sleep(0.2) |
| 256 | |
| 257 | assert status.ok and status.done |
| 258 | with open(output_document_path, "wb") as outfile: |
| 259 | translator.translate_document_download(handle, outfile) |
| 260 | |
| 261 | assert output_document_path.read_text() == example_document_translation |
| 262 | |
| 263 | |
| 264 | def test_translate_document_string(translator, server): |
nothing calls this directly
no test coverage detected