Example #1
0
def test_store_fs_path_filter_instance():
    path_filter = StoreFSPathFilter()
    assert path_filter.pootle_path is None
    assert path_filter.pootle_regex is None
    assert path_filter.fs_path is None
    assert path_filter.fs_regex is None
    # regexes are cached
    path_filter.pootle_path = "/foo"
    path_filter.fs_path = "/bar"
    assert path_filter.pootle_regex is None
    assert path_filter.fs_regex is None
    del path_filter.__dict__["pootle_regex"]
    del path_filter.__dict__["fs_regex"]
    assert (
        path_filter.pootle_regex
        == path_filter.path_regex(path_filter.pootle_path))
    assert (
        path_filter.fs_regex
        == path_filter.path_regex(path_filter.fs_path))
Example #2
0
def test_store_fs_path_filtered(glob):
    project = Project.objects.get(code="project0")
    stores = Store.objects.filter(
        translation_project__project=project)
    for store in stores:
        StoreFS.objects.create(
            store=store,
            path="/fs%s" % store.pootle_path)
    stores_fs = StoreFS.objects.filter(project=project)
    if not glob:
        assert StoreFSPathFilter().filtered(stores_fs) is stores_fs
    else:
        path_filter = StoreFSPathFilter(pootle_path=glob)
        assert (
            list(path_filter.filtered(stores_fs))
            == list(stores_fs.filter(pootle_path__regex=path_filter.pootle_regex)))
        path_filter = StoreFSPathFilter(fs_path="/fs%s" % glob)
        assert (
            list(path_filter.filtered(stores_fs))
            == list(stores_fs.filter(path__regex=path_filter.fs_regex)))
Example #3
0
def test_store_fs_path_filtered(glob):
    project = Project.objects.get(code="project0")
    stores = Store.objects.filter(translation_project__project=project)
    for store in stores:
        StoreFS.objects.create(store=store, path="/fs%s" % store.pootle_path)
    stores_fs = StoreFS.objects.filter(project=project)
    if not glob:
        assert StoreFSPathFilter().filtered(stores_fs) is stores_fs
    else:
        path_filter = StoreFSPathFilter(pootle_path=glob)
        assert (list(path_filter.filtered(stores_fs)) == list(
            stores_fs.filter(pootle_path__regex=path_filter.pootle_regex)))
        path_filter = StoreFSPathFilter(fs_path="/fs%s" % glob)
        assert (list(path_filter.filtered(stores_fs)) == list(
            stores_fs.filter(path__regex=path_filter.fs_regex)))
Example #4
0
def test_store_fs_path_filter_instance():
    path_filter = StoreFSPathFilter()
    assert path_filter.pootle_path is None
    assert path_filter.pootle_regex is None
    assert path_filter.fs_path is None
    assert path_filter.fs_regex is None
    # regexes are cached
    path_filter.pootle_path = "/foo"
    path_filter.fs_path = "/bar"
    assert path_filter.pootle_regex is None
    assert path_filter.fs_regex is None
    del path_filter.__dict__["pootle_regex"]
    del path_filter.__dict__["fs_regex"]
    assert (path_filter.pootle_regex == path_filter.path_regex(
        path_filter.pootle_path))
    assert (path_filter.fs_regex == path_filter.path_regex(
        path_filter.fs_path))