def test_matcher_get_lang(): project = Project.objects.get(code="project0") project.config["pootle_fs.translation_mappings"] = dict( default="/path/to/<language_code>/<dir_path>/<filename>.<ext>") project.config["pootle.core.lang_mapping"] = { "upstream-language0": "language0"} matcher = FSPathMatcher(DummyContext(project)) assert ( matcher.get_language("upstream-language0") == Language.objects.get(code="language0"))
def test_matcher_get_lang(): project = Project.objects.get(code="project0") project.config["pootle_fs.translation_paths"] = dict( default="/path/to/<language_code>/<dir_path>/<filename>.<ext>") project.config["pootle.core.lang_mapping"] = { "upstream-language0": "language0" } matcher = FSPathMatcher(DummyContext(project)) assert (matcher.get_language("upstream-language0") == Language.objects.get( code="language0"))
def test_matcher_matches(settings): settings.POOTLE_FS_PATH = "/path/to" project = Project.objects.get(code="project0") project.config["pootle_fs.translation_paths"] = dict( default="/some/other/path/<language_code>/<dir_path>/<filename>.<ext>") matcher = FSPathMatcher(DummyContext(project)) finder = matcher.get_finder() matches = [] for file_path, matched in finder.dummy_paths: language = matcher.get_language(matched["language_code"]) matched["language_code"] = language.code matches.append((matcher.match_pootle_path(**matched), matcher.relative_path(file_path))) assert matches == list(matcher.matches(None, None))
def test_matcher_matches(settings): settings.POOTLE_FS_PATH = "/path/to" project = Project.objects.get(code="project0") project.config["pootle_fs.translation_paths"] = dict( default="/some/other/path/<language_code>/<dir_path>/<filename>.<ext>" ) matcher = FSPathMatcher(DummyContext(project)) finder = matcher.get_finder() matches = [] for file_path, matched in finder.dummy_paths: language = matcher.get_language(matched["language_code"]) matched["language_code"] = language.code matches.append((matcher.match_pootle_path(**matched), matcher.relative_path(file_path))) assert matches == list(matcher.matches(None, None))