deepl-rb 3.9.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -1
- data/CHANGELOG.md +741 -18
- data/Gemfile +4 -0
- data/README.md +1001 -327
- data/Rakefile +29 -7
- data/VERSION +1 -1
- data/deepl-rb.gemspec +75 -88
- data/lib/deepl/admin_client.rb +208 -0
- data/lib/deepl/api.rb +18 -8
- data/lib/deepl/app_info.rb +19 -0
- data/lib/deepl/client.rb +1284 -0
- data/lib/deepl/configuration.rb +27 -32
- data/lib/deepl/constants/admin_usage_group_by.rb +13 -0
- data/lib/deepl/constants/custom_tag_usage_aggregate_by.rb +13 -0
- data/lib/deepl/constants/document_status_code.rb +17 -0
- data/lib/deepl/constants/language_include.rb +17 -0
- data/lib/deepl/constants/language_resource_name.rb +21 -0
- data/lib/deepl/constants/tag_handling_version.rb +14 -0
- data/lib/deepl/exceptions/authorization_failed.rb +1 -1
- data/lib/deepl/exceptions/bad_request.rb +1 -3
- data/lib/deepl/exceptions/connection_error.rb +40 -0
- data/lib/deepl/exceptions/document_not_ready_error.rb +17 -0
- data/lib/deepl/exceptions/document_translation_error.rb +17 -1
- data/lib/deepl/exceptions/error.rb +13 -1
- data/lib/deepl/exceptions/limit_exceeded.rb +1 -1
- data/lib/deepl/exceptions/not_found.rb +8 -3
- data/lib/deepl/exceptions/quota_exceeded.rb +1 -1
- data/lib/deepl/exceptions/request_entity_too_large.rb +1 -2
- data/lib/deepl/exceptions/request_error.rb +26 -2
- data/lib/deepl/exceptions/server_error.rb +9 -2
- data/lib/deepl/exceptions/translation_memory_job_error.rb +32 -0
- data/lib/deepl/exceptions/validation_error.rb +15 -0
- data/lib/deepl/requests/admin/base.rb +94 -0
- data/lib/deepl/requests/admin/create_developer_key.rb +38 -0
- data/lib/deepl/requests/admin/custom_tag_usage_analytics.rb +38 -0
- data/lib/deepl/requests/admin/list_developer_keys.rb +28 -0
- data/lib/deepl/requests/admin/update_developer_key.rb +35 -0
- data/lib/deepl/requests/admin/usage_analytics.rb +36 -0
- data/lib/deepl/requests/base.rb +313 -65
- data/lib/deepl/requests/correct.rb +51 -0
- data/lib/deepl/requests/document/download.rb +11 -3
- data/lib/deepl/requests/document/get_status.rb +2 -2
- data/lib/deepl/requests/document/upload.rb +56 -20
- data/lib/deepl/requests/glossary/base.rb +30 -0
- data/lib/deepl/requests/glossary/create.rb +18 -18
- data/lib/deepl/requests/glossary/destroy.rb +4 -16
- data/lib/deepl/requests/glossary/entries.rb +6 -14
- data/lib/deepl/requests/glossary/find.rb +3 -13
- data/lib/deepl/requests/glossary/language_pairs.rb +22 -6
- data/lib/deepl/requests/glossary/list.rb +2 -2
- data/lib/deepl/requests/language_resources.rb +41 -0
- data/lib/deepl/requests/languages.rb +25 -6
- data/lib/deepl/requests/languages_for_resource.rb +56 -0
- data/lib/deepl/requests/multilingual_glossary/create.rb +45 -0
- data/lib/deepl/requests/multilingual_glossary/destroy.rb +36 -0
- data/lib/deepl/requests/multilingual_glossary/destroy_dictionary.rb +55 -0
- data/lib/deepl/requests/multilingual_glossary/entries.rb +68 -0
- data/lib/deepl/requests/multilingual_glossary/find.rb +35 -0
- data/lib/deepl/requests/multilingual_glossary/helpers.rb +71 -0
- data/lib/deepl/requests/multilingual_glossary/list.rb +39 -0
- data/lib/deepl/requests/multilingual_glossary/replace_dictionary.rb +41 -0
- data/lib/deepl/requests/multilingual_glossary/update.rb +40 -0
- data/lib/deepl/requests/rephrase.rb +8 -10
- data/lib/deepl/requests/spoken_terms/create.rb +42 -0
- data/lib/deepl/requests/spoken_terms/destroy.rb +36 -0
- data/lib/deepl/requests/spoken_terms/destroy_term_list.rb +42 -0
- data/lib/deepl/requests/spoken_terms/entries.rb +47 -0
- data/lib/deepl/requests/spoken_terms/find.rb +35 -0
- data/lib/deepl/requests/spoken_terms/helpers.rb +74 -0
- data/lib/deepl/requests/spoken_terms/list.rb +35 -0
- data/lib/deepl/requests/spoken_terms/replace_term_list.rb +41 -0
- data/lib/deepl/requests/spoken_terms/update.rb +40 -0
- data/lib/deepl/requests/style_profile/base.rb +83 -0
- data/lib/deepl/requests/style_profile/create.rb +40 -0
- data/lib/deepl/requests/style_profile/destroy.rb +34 -0
- data/lib/deepl/requests/style_profile/find.rb +33 -0
- data/lib/deepl/requests/style_profile/list.rb +43 -0
- data/lib/deepl/requests/style_profile/update.rb +35 -0
- data/lib/deepl/requests/style_rule/create.rb +24 -0
- data/lib/deepl/requests/style_rule/create_custom_instruction.rb +11 -2
- data/lib/deepl/requests/style_rule/destroy.rb +4 -2
- data/lib/deepl/requests/style_rule/destroy_custom_instruction.rb +5 -3
- data/lib/deepl/requests/style_rule/find.rb +4 -2
- data/lib/deepl/requests/style_rule/find_custom_instruction.rb +5 -3
- data/lib/deepl/requests/style_rule/helpers.rb +44 -0
- data/lib/deepl/requests/style_rule/list.rb +3 -1
- data/lib/deepl/requests/style_rule/update.rb +5 -2
- data/lib/deepl/requests/style_rule/update_configured_rules.rb +4 -2
- data/lib/deepl/requests/style_rule/update_custom_instruction.rb +7 -3
- data/lib/deepl/requests/translate.rb +43 -27
- data/lib/deepl/requests/translation_memory/base.rb +1 -4
- data/lib/deepl/requests/translation_memory/create_export.rb +7 -2
- data/lib/deepl/requests/translation_memory/create_import.rb +11 -1
- data/lib/deepl/requests/translation_memory/destroy.rb +1 -1
- data/lib/deepl/requests/translation_memory/find.rb +1 -1
- data/lib/deepl/requests/translation_memory/find_job.rb +1 -1
- data/lib/deepl/requests/translation_memory/list.rb +4 -3
- data/lib/deepl/requests/translation_memory/segments.rb +5 -4
- data/lib/deepl/requests/translation_memory/storage_base.rb +37 -9
- data/lib/deepl/requests/translation_memory/upload_file.rb +1 -1
- data/lib/deepl/requests/usage.rb +28 -1
- data/lib/deepl/requests/write_improvements.rb +42 -0
- data/lib/deepl/resources/admin_usage_report.rb +73 -0
- data/lib/deepl/resources/custom_tag_usage_report.rb +59 -0
- data/lib/deepl/resources/developer_key.rb +57 -0
- data/lib/deepl/resources/document_handle.rb +8 -34
- data/lib/deepl/resources/document_translation_status.rb +14 -7
- data/lib/deepl/resources/language.rb +5 -3
- data/lib/deepl/resources/language_resource.rb +57 -0
- data/lib/deepl/resources/language_support.rb +56 -0
- data/lib/deepl/resources/multilingual_glossary.rb +112 -0
- data/lib/deepl/resources/spoken_terms.rb +61 -0
- data/lib/deepl/resources/style_profile.rb +44 -0
- data/lib/deepl/resources/style_rule.rb +4 -23
- data/lib/deepl/resources/text.rb +18 -2
- data/lib/deepl/resources/translation_memory.rb +8 -2
- data/lib/deepl/resources/translation_memory_import.rb +1 -1
- data/lib/deepl/resources/translation_memory_job.rb +26 -7
- data/lib/deepl/resources/translation_memory_segments.rb +8 -6
- data/lib/deepl/resources/usage.rb +61 -5
- data/lib/deepl/utils/client_builder.rb +89 -0
- data/lib/deepl/utils/document_poller.rb +70 -0
- data/lib/deepl/utils/exception_builder.rb +3 -2
- data/lib/deepl/utils/glossary_entries.rb +30 -0
- data/lib/deepl/utils/http_client_builder.rb +116 -0
- data/lib/deepl/utils/number_parser.rb +34 -0
- data/lib/deepl/utils/output_path.rb +25 -0
- data/lib/deepl/utils/term_validator.rb +33 -0
- data/lib/deepl/utils/time_parser.rb +14 -0
- data/lib/deepl/utils/translation_memory_operations.rb +230 -0
- data/lib/deepl.rb +68 -108
- data/lib/http_client_options.rb +21 -1
- data/lib/version.rb +1 -1
- data/upgrading_to_v4.md +374 -0
- metadata +84 -85
- data/.circleci/config.yml +0 -27
- data/.github/workflows/add_issues_to_kanban.yml +0 -16
- data/.gitlab-ci.yml +0 -179
- data/lib/deepl/document_api.rb +0 -131
- data/lib/deepl/exceptions/not_supported.rb +0 -14
- data/lib/deepl/glossary_api.rb +0 -38
- data/lib/deepl/style_rule_api.rb +0 -61
- data/lib/deepl/translation_memory_api.rb +0 -309
- data/license_checker.sh +0 -8
- data/spec/api/api_spec.rb +0 -20
- data/spec/api/configuration_spec.rb +0 -122
- data/spec/api/deepl_spec.rb +0 -262
- data/spec/constants/constants_spec.rb +0 -158
- data/spec/integration_tests/document_api_spec.rb +0 -211
- data/spec/integration_tests/document_error_paths_spec.rb +0 -33
- data/spec/integration_tests/glossary_api_spec.rb +0 -114
- data/spec/integration_tests/glossary_error_paths_spec.rb +0 -107
- data/spec/integration_tests/integration_test_utils.rb +0 -178
- data/spec/integration_tests/languages_api_spec.rb +0 -54
- data/spec/integration_tests/languages_error_paths_spec.rb +0 -25
- data/spec/integration_tests/rephrase_api_spec.rb +0 -90
- data/spec/integration_tests/rephrase_error_paths_spec.rb +0 -53
- data/spec/integration_tests/smoke_test_spec.rb +0 -24
- data/spec/integration_tests/style_rule_api_spec.rb +0 -117
- data/spec/integration_tests/style_rule_error_paths_spec.rb +0 -45
- data/spec/integration_tests/translate_api_spec.rb +0 -117
- data/spec/integration_tests/translate_error_paths_spec.rb +0 -48
- data/spec/integration_tests/translation_memory_api_spec.rb +0 -244
- data/spec/integration_tests/translation_memory_error_paths_spec.rb +0 -87
- data/spec/integration_tests/usage_api_spec.rb +0 -29
- data/spec/integration_tests/usage_error_paths_spec.rb +0 -18
- data/spec/requests/document/upload_spec.rb +0 -130
- data/spec/requests/extra_body_parameters_types_spec.rb +0 -82
- data/spec/requests/glossary/create_spec.rb +0 -44
- data/spec/requests/glossary/destroy_spec.rb +0 -27
- data/spec/requests/glossary/entries_spec.rb +0 -27
- data/spec/requests/glossary/find_spec.rb +0 -28
- data/spec/requests/glossary/language_pairs_spec.rb +0 -27
- data/spec/requests/glossary/list_spec.rb +0 -27
- data/spec/requests/languages_spec.rb +0 -27
- data/spec/requests/rephrase_spec.rb +0 -46
- data/spec/requests/style_rule/create_custom_instruction_spec.rb +0 -30
- data/spec/requests/style_rule/create_spec.rb +0 -29
- data/spec/requests/style_rule/destroy_custom_instruction_spec.rb +0 -28
- data/spec/requests/style_rule/destroy_spec.rb +0 -27
- data/spec/requests/style_rule/find_custom_instruction_spec.rb +0 -29
- data/spec/requests/style_rule/find_spec.rb +0 -28
- data/spec/requests/style_rule/list_spec.rb +0 -27
- data/spec/requests/style_rule/update_configured_rules_spec.rb +0 -31
- data/spec/requests/style_rule/update_custom_instruction_spec.rb +0 -32
- data/spec/requests/style_rule/update_spec.rb +0 -29
- data/spec/requests/translate_spec.rb +0 -338
- data/spec/requests/translation_memory/create_export_spec.rb +0 -37
- data/spec/requests/translation_memory/create_import_spec.rb +0 -61
- data/spec/requests/translation_memory/destroy_spec.rb +0 -36
- data/spec/requests/translation_memory/download_export_spec.rb +0 -54
- data/spec/requests/translation_memory/find_job_spec.rb +0 -37
- data/spec/requests/translation_memory/find_spec.rb +0 -36
- data/spec/requests/translation_memory/list_spec.rb +0 -27
- data/spec/requests/translation_memory/segments_spec.rb +0 -58
- data/spec/requests/translation_memory/upload_file_spec.rb +0 -55
- data/spec/requests/usage_spec.rb +0 -27
- data/spec/resources/custom_instruction_spec.rb +0 -32
- data/spec/resources/glossary_spec.rb +0 -38
- data/spec/resources/language_pair_spec.rb +0 -23
- data/spec/resources/language_spec.rb +0 -45
- data/spec/resources/style_rule_spec.rb +0 -68
- data/spec/resources/text_spec.rb +0 -23
- data/spec/resources/translation_memory_export_spec.rb +0 -38
- data/spec/resources/translation_memory_import_spec.rb +0 -30
- data/spec/resources/translation_memory_job_spec.rb +0 -109
- data/spec/resources/translation_memory_segments_spec.rb +0 -78
- data/spec/resources/translation_memory_spec.rb +0 -52
- data/spec/resources/usage_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -62
- data/spec/support/live_mock_server.rb +0 -12
- data/spec/support/managed_glossary.rb +0 -65
- data/spec/support/managed_style_rule.rb +0 -17
- data/spec/support/managed_translation_memory.rb +0 -55
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
describe DeepL::GlossaryApi do
|
|
9
|
-
let(:default_glossary_args) do
|
|
10
|
-
{
|
|
11
|
-
name: 'Integration Test Glossary',
|
|
12
|
-
source_lang: 'en',
|
|
13
|
-
target_lang: 'de',
|
|
14
|
-
entries: [%w[Hello Hallo], %w[World Welt]]
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe 'happy path lifecycle' do
|
|
19
|
-
it 'creates, lists, and finds a glossary' do # rubocop:disable RSpec/ExampleLength,RSpec/MultipleExpectations
|
|
20
|
-
with_managed_glossary(**default_glossary_args) do |glossary|
|
|
21
|
-
expect(glossary).to be_a(DeepL::Resources::Glossary)
|
|
22
|
-
expect(glossary.id).to be_a(String)
|
|
23
|
-
expect(glossary.name).to eq(default_glossary_args[:name])
|
|
24
|
-
expect(glossary.entry_count).to eq(2)
|
|
25
|
-
expect(glossary.source_lang).to eq(default_glossary_args[:source_lang])
|
|
26
|
-
expect(glossary.target_lang).to eq(default_glossary_args[:target_lang])
|
|
27
|
-
expect(glossary.ready).to be(true).or be(false)
|
|
28
|
-
expect { Time.iso8601(glossary.creation_time) }.not_to raise_error
|
|
29
|
-
|
|
30
|
-
listed = DeepL.glossaries.list
|
|
31
|
-
expect(listed).to be_an(Array)
|
|
32
|
-
expect(listed.map(&:id)).to include(glossary.id)
|
|
33
|
-
|
|
34
|
-
found = DeepL.glossaries.find(glossary.id)
|
|
35
|
-
expect(found).to be_a(DeepL::Resources::Glossary)
|
|
36
|
-
expect(found.id).to eq(glossary.id)
|
|
37
|
-
expect(found.name).to eq(glossary.name)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe '#language_pairs' do
|
|
43
|
-
it 'returns a non-empty list of supported source/target combos' do
|
|
44
|
-
pairs = DeepL.glossaries.language_pairs
|
|
45
|
-
expect(pairs).to be_an(Array)
|
|
46
|
-
expect(pairs).not_to be_empty
|
|
47
|
-
expect(pairs.first).to be_a(DeepL::Resources::LanguagePair)
|
|
48
|
-
expect(pairs.first.source_lang).to be_a(String)
|
|
49
|
-
expect(pairs.first.target_lang).to be_a(String)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe 'error handling' do
|
|
54
|
-
it 'raises when creating a glossary with an invalid source language code' do
|
|
55
|
-
expect do
|
|
56
|
-
DeepL.glossaries.create(
|
|
57
|
-
'Invalid Lang Glossary',
|
|
58
|
-
'zz',
|
|
59
|
-
'de',
|
|
60
|
-
[%w[Hello Hallo]]
|
|
61
|
-
)
|
|
62
|
-
end.to raise_error(DeepL::Exceptions::RequestError)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe '#destroy' do
|
|
67
|
-
it 'returns the id of the destroyed glossary' do
|
|
68
|
-
glossary = DeepL.glossaries.create(
|
|
69
|
-
default_glossary_args[:name],
|
|
70
|
-
default_glossary_args[:source_lang],
|
|
71
|
-
default_glossary_args[:target_lang],
|
|
72
|
-
default_glossary_args[:entries]
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
expect(DeepL.glossaries.destroy(glossary.id)).to eq(glossary.id)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe '#entries' do
|
|
80
|
-
it 'returns the glossary entries as an array of [source, target] pairs' do # rubocop:disable RSpec/ExampleLength
|
|
81
|
-
with_managed_glossary(**default_glossary_args) do |glossary|
|
|
82
|
-
entries = DeepL.glossaries.entries(glossary.id)
|
|
83
|
-
|
|
84
|
-
expect(entries).to be_an(Array)
|
|
85
|
-
expect(entries).to all(be_an(Array))
|
|
86
|
-
expect(entries.size).to eq(default_glossary_args[:entries].size)
|
|
87
|
-
entries.each do |entry|
|
|
88
|
-
expect(entry.size).to eq(2)
|
|
89
|
-
expect(entry.first).to be_a(String)
|
|
90
|
-
expect(entry.last).to be_a(String)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
describe 'edge cases' do
|
|
97
|
-
it 'accepts Unicode keys and values in glossary entries' do # rubocop:disable RSpec/ExampleLength
|
|
98
|
-
unicode_entries = [
|
|
99
|
-
['Schöne Grüße', 'Best regards'],
|
|
100
|
-
['🚀 rocket', '🚀 fusée'],
|
|
101
|
-
['日本語', 'Japanese'],
|
|
102
|
-
['café', 'kafē']
|
|
103
|
-
]
|
|
104
|
-
args = default_glossary_args.merge(
|
|
105
|
-
name: 'Unicode Glossary',
|
|
106
|
-
entries: unicode_entries
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
with_managed_glossary(**args) do |glossary|
|
|
110
|
-
expect(glossary.entry_count).to eq(unicode_entries.length)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
describe DeepL::GlossaryApi do # rubocop:disable RSpec/SpecFilePathFormat
|
|
9
|
-
include_context 'with a live mock server'
|
|
10
|
-
|
|
11
|
-
let(:nonexistent_glossary_id) { '00000000-0000-0000-0000-000000000000' }
|
|
12
|
-
|
|
13
|
-
let(:valid_glossary_args) do
|
|
14
|
-
{
|
|
15
|
-
name: 'Error Path Test Glossary',
|
|
16
|
-
source_lang: 'en',
|
|
17
|
-
target_lang: 'de',
|
|
18
|
-
entries: [%w[Hello Hallo]]
|
|
19
|
-
}
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe 'AuthorizationFailed (401/403)' do
|
|
23
|
-
let(:unauthorized_glossaries) { described_class.new(unauthorized_api) }
|
|
24
|
-
|
|
25
|
-
it 'is raised by #list when the auth key is invalid' do
|
|
26
|
-
expect { unauthorized_glossaries.list }
|
|
27
|
-
.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'is raised by #language_pairs when the auth key is invalid' do
|
|
31
|
-
expect { unauthorized_glossaries.language_pairs }
|
|
32
|
-
.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'is raised by #create when the auth key is invalid' do
|
|
36
|
-
expect do
|
|
37
|
-
unauthorized_glossaries.create(
|
|
38
|
-
valid_glossary_args[:name],
|
|
39
|
-
valid_glossary_args[:source_lang],
|
|
40
|
-
valid_glossary_args[:target_lang],
|
|
41
|
-
valid_glossary_args[:entries]
|
|
42
|
-
)
|
|
43
|
-
end.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'is raised by #find when the auth key is invalid' do
|
|
47
|
-
expect { unauthorized_glossaries.find(nonexistent_glossary_id) }
|
|
48
|
-
.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'is raised by #destroy when the auth key is invalid' do
|
|
52
|
-
expect { unauthorized_glossaries.destroy(nonexistent_glossary_id) }
|
|
53
|
-
.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe 'NotFound (404)' do
|
|
58
|
-
it 'is raised by #find for a well-formed but unknown glossary id' do
|
|
59
|
-
expect { DeepL.glossaries.find(nonexistent_glossary_id) }
|
|
60
|
-
.to raise_error(DeepL::Exceptions::NotFound)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'is raised by #destroy for a well-formed but unknown glossary id' do
|
|
64
|
-
expect { DeepL.glossaries.destroy(nonexistent_glossary_id) }
|
|
65
|
-
.to raise_error(DeepL::Exceptions::NotFound)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe 'BadRequest (400) from #create' do
|
|
70
|
-
it 'is raised for an invalid source language code' do
|
|
71
|
-
expect do
|
|
72
|
-
DeepL.glossaries.create(
|
|
73
|
-
valid_glossary_args[:name],
|
|
74
|
-
'zz',
|
|
75
|
-
valid_glossary_args[:target_lang],
|
|
76
|
-
valid_glossary_args[:entries]
|
|
77
|
-
)
|
|
78
|
-
end.to raise_error(DeepL::Exceptions::BadRequest)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe 'BadRequest (400) from a malformed glossary id' do
|
|
83
|
-
let(:malformed_uuid) { 'invalid-uuid' }
|
|
84
|
-
|
|
85
|
-
it 'is raised by #find for a malformed glossary id' do
|
|
86
|
-
expect { DeepL.glossaries.find(malformed_uuid) }
|
|
87
|
-
.to raise_error(DeepL::Exceptions::BadRequest)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it 'is raised by #destroy for a malformed glossary id' do
|
|
91
|
-
expect { DeepL.glossaries.destroy(malformed_uuid) }
|
|
92
|
-
.to raise_error(DeepL::Exceptions::BadRequest)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'is raised by #entries for a malformed glossary id' do
|
|
96
|
-
expect { DeepL.glossaries.entries(malformed_uuid) }
|
|
97
|
-
.to raise_error(DeepL::Exceptions::BadRequest)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe 'NotFound (404) from #entries' do
|
|
102
|
-
it 'is raised for a well-formed but unknown glossary id' do
|
|
103
|
-
expect { DeepL.glossaries.entries(nonexistent_glossary_id) }
|
|
104
|
-
.to raise_error(DeepL::Exceptions::NotFound)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'securerandom'
|
|
7
|
-
require 'tempfile'
|
|
8
|
-
|
|
9
|
-
module IntegrationTestUtils # rubocop:disable Metrics/ModuleLength
|
|
10
|
-
EXAMPLE_TEXT = {
|
|
11
|
-
'BG' => 'протонен лъч',
|
|
12
|
-
'CS' => 'protonový paprsek',
|
|
13
|
-
'DA' => 'protonstråle',
|
|
14
|
-
'DE' => 'Protonenstrahl',
|
|
15
|
-
'EL' => 'δέσμη πρωτονίων',
|
|
16
|
-
'EN' => 'proton beam',
|
|
17
|
-
'EN-US' => 'proton beam',
|
|
18
|
-
'EN-GB' => 'proton beam',
|
|
19
|
-
'ES' => 'haz de protones',
|
|
20
|
-
'ET' => 'prootonikiirgus',
|
|
21
|
-
'FI' => 'protonisäde',
|
|
22
|
-
'FR' => 'faisceau de protons',
|
|
23
|
-
'HU' => 'protonnyaláb',
|
|
24
|
-
'ID' => 'berkas proton',
|
|
25
|
-
'IT' => 'fascio di protoni',
|
|
26
|
-
'JA' => '陽子ビーム',
|
|
27
|
-
'KO' => '양성자 빔',
|
|
28
|
-
'LT' => 'protonų spindulys',
|
|
29
|
-
'LV' => 'protonu staru kūlis',
|
|
30
|
-
'NB' => 'protonstråle',
|
|
31
|
-
'NL' => 'protonenbundel',
|
|
32
|
-
'PL' => 'wiązka protonów',
|
|
33
|
-
'PT' => 'feixe de prótons',
|
|
34
|
-
'PT-BR' => 'feixe de prótons',
|
|
35
|
-
'PT-PT' => 'feixe de prótons',
|
|
36
|
-
'RO' => 'fascicul de protoni',
|
|
37
|
-
'RU' => 'протонный луч',
|
|
38
|
-
'SK' => 'protónový lúč',
|
|
39
|
-
'SL' => 'protonski žarek',
|
|
40
|
-
'SV' => 'protonstråle',
|
|
41
|
-
'TR' => 'proton ışını',
|
|
42
|
-
'UK' => 'протонний пучок',
|
|
43
|
-
'ZH' => '质子束'
|
|
44
|
-
}.freeze
|
|
45
|
-
|
|
46
|
-
def mock_server?
|
|
47
|
-
ENV.key?('DEEPL_MOCK_SERVER_PORT')
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def mock_proxy_server?
|
|
51
|
-
ENV.key?('DEEPL_MOCK_PROXY_SERVER_PORT')
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def real_server?
|
|
55
|
-
!mock_server?
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def setup
|
|
59
|
-
@input_file = nil
|
|
60
|
-
@input_file_extension = nil
|
|
61
|
-
@output_file = nil
|
|
62
|
-
DeepL.configure do |config|
|
|
63
|
-
config.auth_key = 'your-api-token'
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def teardown
|
|
68
|
-
unless @input_file.nil?
|
|
69
|
-
@input_file.close
|
|
70
|
-
@input_file.unlink
|
|
71
|
-
end
|
|
72
|
-
return if @output_file.nil?
|
|
73
|
-
|
|
74
|
-
@output_file.close
|
|
75
|
-
@output_file.unlink
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def example_document_path(document_language)
|
|
79
|
-
setup_example_document(EXAMPLE_TEXT[document_language])
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def example_large_document_path(document_language)
|
|
83
|
-
setup_example_document("#{EXAMPLE_TEXT[document_language]}\n" * 1000)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def setup_example_document(file_content)
|
|
87
|
-
@input_file_base_name = 'example_input_document' if @input_file_base_name.nil?
|
|
88
|
-
@input_file_extension = '.txt' if @input_file_extension.nil?
|
|
89
|
-
if @input_file.nil?
|
|
90
|
-
@input_file = Tempfile.new([@input_file_base_name, @input_file_extension])
|
|
91
|
-
@input_file.write(file_content)
|
|
92
|
-
@input_file.close
|
|
93
|
-
end
|
|
94
|
-
@input_file.path
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def example_document_translation(document_language)
|
|
98
|
-
EXAMPLE_TEXT[document_language]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def example_large_document_translation(document_language)
|
|
102
|
-
"#{EXAMPLE_TEXT[document_language]}\n" * 1000
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def output_document_path
|
|
106
|
-
@output_file = Tempfile.new('example_output_document') if @output_file.nil?
|
|
107
|
-
@output_file.path
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# For detailed explanations of these header, check the deepl-mock README.md
|
|
111
|
-
def no_response_header(no_response_count)
|
|
112
|
-
{ 'mock-server-session-no-response-count' => no_response_count.to_s,
|
|
113
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def respond_with_429_header(response_count)
|
|
117
|
-
{ 'mock-server-session-429-count' => response_count.to_s,
|
|
118
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def set_character_limit_header(response_count) # rubocop:disable Naming/AccessorMethodName
|
|
122
|
-
{ 'mock-server-session-init-character-limit' => response_count.to_s,
|
|
123
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def set_document_limit_header(response_count) # rubocop:disable Naming/AccessorMethodName
|
|
127
|
-
{ 'mock-server-session-init-document-limit' => response_count.to_s,
|
|
128
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def set_team_document_limit_header(response_count) # rubocop:disable Naming/AccessorMethodName
|
|
132
|
-
{ 'mock-server-session-init-team-document-limit' => response_count.to_s,
|
|
133
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def fail_docs_header(response_count)
|
|
137
|
-
{ 'mock-server-session-doc-failure' => response_count.to_s,
|
|
138
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def doc_translation_queue_time_header(response_count)
|
|
142
|
-
{ 'mock-server-session-doc-queue-time' => response_count.to_s,
|
|
143
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def doc_translation_translation_time_header(response_count)
|
|
147
|
-
{ 'mock-server-session-doc-translate-time' => response_count.to_s,
|
|
148
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
# Makes a translation memory import or export job report its non-terminal status, such as
|
|
152
|
-
# `awaiting_input` for an uploaded import, for the given number of status queries before it
|
|
153
|
-
# completes. Without it a job completes on the first query.
|
|
154
|
-
def tm_job_processing_polls_header(poll_count)
|
|
155
|
-
{ 'mock-server-session-tm-job-processing-polls' => poll_count.to_s,
|
|
156
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def expect_proxy_header(response_count)
|
|
160
|
-
{ 'mock-server-session-expect-proxy' => response_count.to_s,
|
|
161
|
-
'mock-server-session' => SecureRandom.uuid }
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
shared_context 'with temp dir' do
|
|
166
|
-
around do |example|
|
|
167
|
-
Dir.mktmpdir('deepl-rspec-') do |dir|
|
|
168
|
-
@temp_dir = dir
|
|
169
|
-
example.run
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
attr_reader :temp_dir, :input_file_base_name, :input_file_extension
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
RSpec.configure do |c|
|
|
177
|
-
c.include IntegrationTestUtils
|
|
178
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
# Covers GET /v2/languages; the SDK has no v3 languages endpoint.
|
|
9
|
-
describe 'DeepL.languages' do # rubocop:disable RSpec/DescribeClass
|
|
10
|
-
describe 'source languages' do
|
|
11
|
-
it 'returns a non-empty array of Language resources with common codes' do
|
|
12
|
-
languages = DeepL.languages
|
|
13
|
-
|
|
14
|
-
expect(languages).to be_an(Array)
|
|
15
|
-
expect(languages).not_to be_empty
|
|
16
|
-
expect(languages).to all(be_a(DeepL::Resources::Language))
|
|
17
|
-
expect(languages.first).to respond_to(:code, :name)
|
|
18
|
-
|
|
19
|
-
codes = languages.map(&:code)
|
|
20
|
-
expect(codes).to include('EN', 'DE')
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe 'target languages' do
|
|
25
|
-
it 'returns target entries that include both formality-supporting and non-supporting members' do
|
|
26
|
-
languages = DeepL.languages(type: :target)
|
|
27
|
-
|
|
28
|
-
expect(languages).to be_an(Array)
|
|
29
|
-
expect(languages).not_to be_empty
|
|
30
|
-
expect(languages).to all(be_a(DeepL::Resources::Language))
|
|
31
|
-
|
|
32
|
-
formalities = languages.map(&:supports_formality?)
|
|
33
|
-
expect(formalities).to include(true)
|
|
34
|
-
expect(formalities).to include(false)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'raises NotSupported when supports_formality? is called on a source-language entry' do
|
|
38
|
-
source_languages = DeepL.languages
|
|
39
|
-
|
|
40
|
-
expect { source_languages.first.supports_formality? }
|
|
41
|
-
.to raise_error(DeepL::Exceptions::NotSupported)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe 'source vs target counts' do
|
|
46
|
-
it 'returns sensible (>20) counts for both source and target listings' do
|
|
47
|
-
source_languages = DeepL.languages
|
|
48
|
-
target_languages = DeepL.languages(type: :target)
|
|
49
|
-
|
|
50
|
-
expect(source_languages.size).to be > 20
|
|
51
|
-
expect(target_languages.size).to be > 20
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
describe 'DeepL.languages error paths' do # rubocop:disable RSpec/DescribeClass
|
|
9
|
-
include_context 'with a live mock server'
|
|
10
|
-
|
|
11
|
-
describe 'authorization failures' do
|
|
12
|
-
it 'raises AuthorizationFailed when the auth key is invalid' do
|
|
13
|
-
request = DeepL::Requests::Languages.new(unauthorized_api)
|
|
14
|
-
|
|
15
|
-
expect { request.request }.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe 'bad request errors' do
|
|
20
|
-
it 'raises BadRequest for an unsupported languages type' do
|
|
21
|
-
expect { DeepL.languages(type: :invalid) }
|
|
22
|
-
.to raise_error(DeepL::Exceptions::BadRequest)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
describe 'DeepL.rephrase' do # rubocop:disable RSpec/DescribeClass
|
|
9
|
-
describe 'happy path' do
|
|
10
|
-
it 'rephrases an English sentence into English and returns a Text resource' do
|
|
11
|
-
result = DeepL.rephrase('As Gregor Samsa awoke one morning he found himself transformed.',
|
|
12
|
-
'en')
|
|
13
|
-
|
|
14
|
-
expect(result).to be_a(DeepL::Resources::Text)
|
|
15
|
-
expect(result.text).to be_a(String)
|
|
16
|
-
expect(result.text).not_to be_empty
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe 'error path' do
|
|
21
|
-
it 'raises a bad request error for an invalid writing_style value' do
|
|
22
|
-
expect do
|
|
23
|
-
DeepL.rephrase('As Gregor Samsa awoke one morning he found himself transformed.',
|
|
24
|
-
'en', 'totally_invalid_style')
|
|
25
|
-
end.to raise_error(DeepL::Exceptions::BadRequest)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe 'edge case' do
|
|
30
|
-
it 'rephrases with a writing_style option applied' do
|
|
31
|
-
result = DeepL.rephrase('As Gregor Samsa awoke one morning he found himself transformed.',
|
|
32
|
-
'en', 'business')
|
|
33
|
-
|
|
34
|
-
expect(result).to be_a(DeepL::Resources::Text)
|
|
35
|
-
expect(result.text).to be_a(String)
|
|
36
|
-
expect(result.text).not_to be_empty
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'rephrases with a tone option applied' do
|
|
40
|
-
result = DeepL.rephrase('As Gregor Samsa awoke one morning he found himself transformed.',
|
|
41
|
-
'en', nil, 'friendly')
|
|
42
|
-
|
|
43
|
-
expect(result).to be_a(DeepL::Resources::Text)
|
|
44
|
-
expect(result.text).to be_a(String)
|
|
45
|
-
expect(result.text).not_to be_empty
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'rephrases an array of texts with a tone applied' do
|
|
49
|
-
texts = [
|
|
50
|
-
'As Gregor Samsa awoke one morning he found himself transformed.',
|
|
51
|
-
'He lay on his armour-like back, and if he lifted his head a little.'
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
results = DeepL.rephrase(texts, 'en', nil, 'friendly')
|
|
55
|
-
|
|
56
|
-
expect(results).to be_an(Array)
|
|
57
|
-
expect(results.size).to eq(2)
|
|
58
|
-
expect(results).to all(be_a(DeepL::Resources::Text))
|
|
59
|
-
expect(results.map(&:text)).to all(be_a(String).and(satisfy { |t| !t.empty? }))
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'rephrases an array of texts with a writing_style applied' do
|
|
63
|
-
texts = [
|
|
64
|
-
'As Gregor Samsa awoke one morning he found himself transformed.',
|
|
65
|
-
'He lay on his armour-like back, and if he lifted his head a little.'
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
results = DeepL.rephrase(texts, 'en', 'business')
|
|
69
|
-
|
|
70
|
-
expect(results).to be_an(Array)
|
|
71
|
-
expect(results.size).to eq(2)
|
|
72
|
-
expect(results).to all(be_a(DeepL::Resources::Text))
|
|
73
|
-
expect(results.map(&:text)).to all(be_a(String).and(satisfy { |t| !t.empty? }))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it 'rephrases an array of texts and returns an array of Text resources' do
|
|
77
|
-
texts = [
|
|
78
|
-
'As Gregor Samsa awoke one morning he found himself transformed.',
|
|
79
|
-
'He lay on his armour-like back, and if he lifted his head a little.'
|
|
80
|
-
]
|
|
81
|
-
|
|
82
|
-
results = DeepL.rephrase(texts, 'en')
|
|
83
|
-
|
|
84
|
-
expect(results).to be_an(Array)
|
|
85
|
-
expect(results.size).to eq(2)
|
|
86
|
-
expect(results).to all(be_a(DeepL::Resources::Text))
|
|
87
|
-
expect(results.map(&:text)).to all(be_a(String).and(satisfy { |t| !t.empty? }))
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'securerandom'
|
|
7
|
-
require 'spec_helper'
|
|
8
|
-
|
|
9
|
-
describe 'DeepL.rephrase error paths' do # rubocop:disable RSpec/DescribeClass
|
|
10
|
-
include IntegrationTestUtils
|
|
11
|
-
|
|
12
|
-
include_context 'with a live mock server'
|
|
13
|
-
|
|
14
|
-
let(:sample_text) { 'As Gregor Samsa awoke one morning he found himself transformed.' }
|
|
15
|
-
|
|
16
|
-
def rephrase_with_fresh_user(headers)
|
|
17
|
-
fresh_auth_key = "rephrase-err-#{SecureRandom.uuid}"
|
|
18
|
-
config = DeepL::Configuration.new(auth_key: fresh_auth_key)
|
|
19
|
-
config.max_network_retries = 0
|
|
20
|
-
api = DeepL::API.new(config)
|
|
21
|
-
DeepL::Requests::Rephrase.new(api, sample_text, 'en', nil, nil, {}, headers).request
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe 'authorization failures' do
|
|
25
|
-
it 'raises AuthorizationFailed when called with an invalid auth_key' do
|
|
26
|
-
request = DeepL::Requests::Rephrase.new(unauthorized_api, sample_text, 'en')
|
|
27
|
-
|
|
28
|
-
expect { request.request }.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe 'bad request errors' do
|
|
33
|
-
it 'raises BadRequest for an unsupported target_lang code' do
|
|
34
|
-
expect do
|
|
35
|
-
DeepL.rephrase(sample_text, 'zzz')
|
|
36
|
-
end.to raise_error(DeepL::Exceptions::BadRequest)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'raises BadRequest when both writing_style and tone are provided' do
|
|
40
|
-
expect do
|
|
41
|
-
DeepL.rephrase(sample_text, 'en', 'business', 'friendly')
|
|
42
|
-
end.to raise_error(DeepL::Exceptions::BadRequest)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe 'rate limiting' do
|
|
47
|
-
it 'raises LimitExceeded when the server responds with 429', :mock_server_only do
|
|
48
|
-
expect do
|
|
49
|
-
rephrase_with_fresh_user(respond_with_429_header(1))
|
|
50
|
-
end.to raise_error(DeepL::Exceptions::LimitExceeded)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 DeepL SE (https://www.deepl.com)
|
|
2
|
-
# Use of this source code is governed by an MIT
|
|
3
|
-
# license that can be found in the LICENSE file.
|
|
4
|
-
# frozen_string_literal: true
|
|
5
|
-
|
|
6
|
-
require 'spec_helper'
|
|
7
|
-
|
|
8
|
-
describe 'SDK smoke test', :integration do # rubocop:disable RSpec/DescribeClass
|
|
9
|
-
it 'exercises translate, glossaries.list, and usage end-to-end' do # rubocop:disable RSpec/ExampleLength
|
|
10
|
-
source_text = 'Hello, world!'
|
|
11
|
-
result = DeepL.translate(source_text, 'EN', 'DE')
|
|
12
|
-
expect(result).to be_a(DeepL::Resources::Text)
|
|
13
|
-
expect(result.text).to be_a(String)
|
|
14
|
-
expect(result.text).not_to be_empty
|
|
15
|
-
expect(result.text).not_to eq(source_text)
|
|
16
|
-
|
|
17
|
-
glossaries = DeepL.glossaries.list
|
|
18
|
-
expect(glossaries).to be_an(Array)
|
|
19
|
-
|
|
20
|
-
usage = DeepL.usage
|
|
21
|
-
expect(usage).to be_a(DeepL::Resources::Usage)
|
|
22
|
-
expect(usage).to respond_to(:character_count, :character_limit)
|
|
23
|
-
end
|
|
24
|
-
end
|