Exemplo n.º 1
0
def test_matcher_matches_excluded_mapped_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]
    project0.config["pootle.core.lang_mapping"] = OrderedDict(
        [["%s_FOO" % language0.code, language0.code]])
    matcher = FSPathMatcher(DummyContext(project0))
    assert matcher.excluded_languages == ["%s_FOO" % language0.code]
    assert matcher.get_finder().exclude_languages == ["%s_FOO" % language0.code]
    assert not any(
        m[0].startswith("/%s/" % language0.code)
        for m in matcher.matches(None, None))
    assert matcher.matches(None, None)
Exemplo n.º 2
0
def test_matcher_matches_excluded_mapped_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]
    project0.config["pootle.core.lang_mapping"] = OrderedDict(
        [["%s_FOO" % language0.code, language0.code]])
    matcher = FSPathMatcher(DummyContext(project0))
    assert matcher.excluded_languages == ["%s_FOO" % language0.code]
    assert matcher.get_finder().exclude_languages == [
        "%s_FOO" % language0.code
    ]
    assert not any(m[0].startswith("/%s/" % language0.code)
                   for m in matcher.matches(None, None))
    assert matcher.matches(None, None)
Exemplo n.º 3
0
def test_matcher_matches_missing_langs(settings, caplog):
    settings.POOTLE_FS_WORKING_PATH = "/path/to"
    project = Project.objects.get(code="project0")
    project.config["pootle_fs.translation_mappings"] = dict(
        default="/some/other/path/<language_code>/<dir_path>/<filename>.<ext>")
    project.config["pootle.core.lang_mapping"] = {
        "language0": "language0-DOES_NOT_EXIST",
        "language1": "language1-DOES_NOT_EXIST"}

    matcher = FSPathMatcher(DummyContext(project))
    assert list(matcher.matches(None, None)) == []
    assert (
        "Could not import files for languages: language0, language1"
        in caplog.text)
Exemplo n.º 4
0
def test_matcher_matches_missing_langs(settings, caplog):
    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>")
    project.config["pootle.core.lang_mapping"] = {
        "language0": "language0-DOES_NOT_EXIST",
        "language1": "language1-DOES_NOT_EXIST"
    }

    matcher = FSPathMatcher(DummyContext(project))
    assert list(matcher.matches(None, None)) == []
    assert ("Could not import files for languages: language0, language1"
            in caplog.text)
Exemplo n.º 5
0
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))
Exemplo n.º 6
0
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))