Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /mardiros_fastlife /tests /unittests /services /test_translations.py
| from pathlib import Path | |
| from fastlife.service.translations import ( | |
| LocalizerFactory, | |
| MergedTranslations, | |
| find_mo_files, | |
| ) | |
| from fastlife.shared_utils.resolver import resolve_path | |
| def test_find_mo_files(): | |
| root_path = resolve_path("tests.fastlife_app:locales") | |
| list_of_mo = set(find_mo_files(root_path)) | |
| assert list_of_mo == { | |
| ( | |
| "en", | |
| "fastlife_test", | |
| Path(root_path) / "en" / "LC_MESSAGES" / "fastlife_test.mo", | |
| ), | |
| ( | |
| "fr", | |
| "fastlife_test", | |
| Path(root_path) / "fr" / "LC_MESSAGES" / "fastlife_test.mo", | |
| ), | |
| } | |
| def test_load(): | |
| factory = LocalizerFactory() | |
| factory.load("tests.fastlife_app:locales") | |
| assert set( | |
| factory._translations.translations.keys(), # type: ignore | |
| ) == {"en", "fr"} | |
| class DummyTranslations: | |
| def __init__(self) -> None: | |
| self._catalog = {"a": "A"} | |
| def plural(self, i: int) -> int: | |
| return int(i > 1) | |
| def test_merged_translation(): | |
| trans = MergedTranslations() | |
| assert trans._catalog == {} # type: ignore | |
| assert trans.plural(0) == 1 | |
| assert trans.plural(1) == 0 | |
| assert trans.plural(2) == 1 | |
| trans.merge(DummyTranslations()) # type: ignore | |
| assert trans.plural(0) == 0 | |
| assert trans.plural(1) == 0 | |
| assert trans.plural(2) == 1 | |
Xet Storage Details
- Size:
- 1.36 kB
- Xet hash:
- d2f27fa15ea7a03321a8ea7723b9cbd775132569fc9eb84f79e3de385f5d58e0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.