Updated docs

This commit is contained in:
2023-02-20 15:55:20 +01:00
parent 48d0daabf5
commit 9e28dce5ce
632 changed files with 10917 additions and 6775 deletions

View File

@@ -1 +1 @@
# imports:
# imports:

View File

@@ -7,7 +7,6 @@ from unittests_cli.constants import TRANSLATION_PATH
class TranslationTestCase(unittest.TestCase):
def __init__(self, methodName: str):
unittest.TestCase.__init__(self, methodName)
self._translation: Optional[TranslationService] = None
@@ -17,51 +16,45 @@ class TranslationTestCase(unittest.TestCase):
os.chdir(os.path.abspath(TRANSLATION_PATH))
self._translation = TranslationService()
settings = TranslationSettings()
settings.from_dict({
"Languages": [
"de",
"en"
],
"DefaultLanguage": "en"
})
settings.from_dict({"Languages": ["de", "en"], "DefaultLanguage": "en"})
self._translation.load_by_settings(settings)
self._translation.set_default_lang('de')
self._translation.set_default_lang("de")
self._translate = TranslatePipe(self._translation)
def cleanUp(self):
pass
def test_service(self):
self.assertEqual('Hallo Welt', self._translation.translate('main.text.hello_world'))
self._translation.set_lang('en')
self.assertEqual('Hello World', self._translation.translate('main.text.hello_world'))
self.assertEqual("Hallo Welt", self._translation.translate("main.text.hello_world"))
self._translation.set_lang("en")
self.assertEqual("Hello World", self._translation.translate("main.text.hello_world"))
with self.assertRaises(KeyError) as ctx:
self._translation.translate('main.text.hallo_welt')
self._translation.translate("main.text.hallo_welt")
self.assertTrue(type(ctx.exception) == KeyError)
self.assertIn('Translation main.text.hallo_welt not found', str(ctx.exception))
self.assertIn("Translation main.text.hallo_welt not found", str(ctx.exception))
with self.assertRaises(FileNotFoundError) as ctx:
self._translation.load('DE')
self._translation.load("DE")
self.assertTrue(type(ctx.exception) == FileNotFoundError)
with self.assertRaises(KeyError) as ctx:
self._translation.set_lang('DE')
self._translation.set_lang("DE")
self.assertTrue(type(ctx.exception) == KeyError)
with self.assertRaises(KeyError) as ctx:
self._translation.set_default_lang('DE')
self._translation.set_default_lang("DE")
self.assertTrue(type(ctx.exception) == KeyError)
def test_pipe(self):
self.assertEqual('Hallo Welt', self._translate.transform('main.text.hello_world'))
self._translation.set_lang('en')
self.assertEqual('Hello World', self._translate.transform('main.text.hello_world'))
self.assertEqual("Hallo Welt", self._translate.transform("main.text.hello_world"))
self._translation.set_lang("en")
self.assertEqual("Hello World", self._translate.transform("main.text.hello_world"))
with self.assertRaises(KeyError) as ctx:
self._translation.translate('main.text.hallo_welt')
self._translation.translate("main.text.hallo_welt")
self.assertTrue(type(ctx.exception) == KeyError)
self.assertIn('Translation main.text.hallo_welt not found', str(ctx.exception))
self.assertIn("Translation main.text.hallo_welt not found", str(ctx.exception))

View File

@@ -6,7 +6,6 @@ from unittests_translation.translation_test_case import TranslationTestCase
class TranslationTestSuite(unittest.TestSuite):
def __init__(self):
unittest.TestSuite.__init__(self)
@@ -14,9 +13,7 @@ class TranslationTestSuite(unittest.TestSuite):
self._result: Optional[TestResult] = None
self._is_online = True
active_tests = [
TranslationTestCase
]
active_tests = [TranslationTestCase]
for test in active_tests:
self.addTests(loader.loadTestsFromTestCase(test))

View File

@@ -2,8 +2,8 @@
"ProjectSettings": {
"Name": "unittests_translation",
"Version": {
"Major": "2022",
"Minor": "12",
"Major": "2023",
"Minor": "2",
"Micro": "0"
},
"Author": "",
@@ -16,11 +16,11 @@
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"cpl-core>=2022.12.0",
"cpl-translation>=2022.12.0"
"cpl-core>=2023.2.0",
"cpl-translation>=2023.2.0"
],
"DevDependencies": [
"cpl-cli>=2022.12.0"
"cpl-cli>=2023.2.0"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {},