Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Technik
protocol-translation-live
Commits
94dcfe37
Commit
94dcfe37
authored
Apr 06, 2022
by
Jakob Lerch
Browse files
add test for translation
parent
b5d46091
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_libretranslate.py
0 → 100644
View file @
94dcfe37
from
configparser
import
ConfigParser
import
json
import
requests
from
functools
import
cache
import
protocol_translation.translation
as
translation
def
init
():
api_keys
=
ConfigParser
()
api_keys
.
read
(
"api_keys.conf"
)
t
=
LibreTranslate
(
"https://translate.fem-net.de"
,
api_keys
[
"libretranslate_key"
])
return
t
def
test_translate
():
t
=
init
()
text_de
=
"Dies ist ein Ball."
text_en
=
"this is a ball."
assert
t
.
translate
(
text_de
,
"de"
,
"en"
)
==
text_en
def
test_translate_empty
():
t
=
init
()
text_de
=
""
text_en
=
""
assert
t
.
translate
(
text_de
,
"de"
,
"en"
)
==
text_en
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment