def test_matcher_finder(settings): settings.POOTLE_FS_PATH = "/path/to" project = Project.objects.get(code="project0") project.config["pootle_fs.translation_paths"] = dict(default="/<language_code>/<dir_path>/<filename>.<ext>") matcher = FSPathMatcher(DummyContext(project)) finder = matcher.get_finder() assert isinstance(finder, DummyFinder) assert finder.translation_path == matcher.translation_path finder = matcher.get_finder(fs_path="bar") assert finder.translation_path == matcher.translation_path assert finder.path_filters == ["bar"]
def test_matcher_finder(settings): settings.POOTLE_FS_PATH = "/path/to" project = Project.objects.get(code="project0") project.config["pootle_fs.translation_paths"] = dict( default="/<language_code>/<dir_path>/<filename>.<ext>") matcher = FSPathMatcher(DummyContext(project)) finder = matcher.get_finder() assert isinstance(finder, DummyFinder) assert finder.translation_path == matcher.translation_path finder = matcher.get_finder(fs_path="bar") assert finder.translation_path == matcher.translation_path assert finder.path_filters == ["bar"]
def test_matcher_matches_excluded_langs(settings, caplog, project0, language0): settings.POOTLE_FS_WORKING_PATH = os.sep.join(['', 'path', 'to']) project0.config["pootle_fs.translation_mappings"] = dict( default="/some/other/path/<language_code>/<dir_path>/<filename>.<ext>") project0.config["pootle.fs.excluded_languages"] = [language0.code] matcher = FSPathMatcher(DummyContext(project0)) assert matcher.excluded_languages == [language0.code] assert matcher.get_finder().exclude_languages == [language0.code] assert not any(m[0].startswith("/%s/" % language0.code) for m in matcher.matches(None, None))
def test_matcher_matches_excluded_langs(settings, caplog, project0, language0): settings.POOTLE_FS_WORKING_PATH = os.sep.join(['', 'path', 'to']) project0.config["pootle_fs.translation_mappings"] = dict( default="/some/other/path/<language_code>/<dir_path>/<filename>.<ext>") project0.config["pootle.fs.excluded_languages"] = [language0.code] matcher = FSPathMatcher(DummyContext(project0)) assert matcher.excluded_languages == [language0.code] assert matcher.get_finder().exclude_languages == [language0.code] assert not any( m[0].startswith("/%s/" % language0.code) for m in 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))
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))