Example #1
0
def test_matcher_make_pootle_path(settings):
    settings.POOTLE_FS_WORKING_PATH = "/path/to"
    project = Project.objects.get(code="project0")
    project.config["pootle_fs.translation_mappings"] = dict(
        default="/path/to/<language_code>/<dir_path>/<filename>.<ext>")
    matcher = FSPathMatcher(DummyContext(project))
    assert matcher.make_pootle_path() is None
    # must provide language_code, filename and ext at a min
    assert matcher.make_pootle_path(language_code="foo") is None
    assert (
        matcher.make_pootle_path(language_code="foo", filename="bar")
        is None)
    assert (
        matcher.make_pootle_path(language_code="foo", ext="baz")
        is None)
    assert (
        matcher.make_pootle_path(
            language_code="foo", filename="bar", ext="baz")
        == "/foo/%s/bar.baz" % project.code)
    assert (
        matcher.make_pootle_path(
            language_code="foo", filename="bar", ext="baz", dir_path="sub/dir")
        == u'/foo/%s/sub/dir/bar.baz' % project.code)
    assert (
        matcher.make_pootle_path(
            language_code="foo", filename="bar", ext="baz", dir_path="sub/dir/")
        == u'/foo/%s/sub/dir/bar.baz' % project.code)
    assert (
        matcher.make_pootle_path(
            language_code="foo", filename="bar", ext="baz", dir_path="/sub/dir")
        == u'/foo/%s/sub/dir/bar.baz' % project.code)
Example #2
0
def test_matcher_make_pootle_path(settings):
    settings.POOTLE_FS_PATH = "/path/to"
    project = Project.objects.get(code="project0")
    project.config["pootle_fs.translation_paths"] = dict(
        default="/path/to/<language_code>/<dir_path>/<filename>.<ext>")
    matcher = FSPathMatcher(DummyContext(project))
    assert matcher.make_pootle_path() is None
    # must provide language_code, filename and ext at a min
    assert matcher.make_pootle_path(language_code="foo") is None
    assert (matcher.make_pootle_path(language_code="foo", filename="bar") is
            None)
    assert (matcher.make_pootle_path(language_code="foo", ext="baz") is None)
    assert (matcher.make_pootle_path(language_code="foo",
                                     filename="bar",
                                     ext="baz") == "/foo/%s/bar.baz" %
            project.code)
    assert (matcher.make_pootle_path(
        language_code="foo", filename="bar", ext="baz",
        dir_path="sub/dir") == u'/foo/%s/sub/dir/bar.baz' % project.code)
    assert (matcher.make_pootle_path(
        language_code="foo", filename="bar", ext="baz",
        dir_path="sub/dir/") == u'/foo/%s/sub/dir/bar.baz' % project.code)
    assert (matcher.make_pootle_path(
        language_code="foo", filename="bar", ext="baz",
        dir_path="/sub/dir") == u'/foo/%s/sub/dir/bar.baz' % project.code)