Пример #1
0
def test_recursive_linker_iteration(fs_fac, page_path, expected):
    fs = fs_fac()
    with mock_fs_scope(fs):
        app = fs.getApp()
        app.config.set('site/pretty_urls', True)
        src = app.getSource('pages')
        linker = Linker(src, os.path.dirname(page_path),
                        root_page_path=page_path)
        actual = list(iter(linker.allpages))

        assert len(actual) == len(expected)
        for i, (a, e) in enumerate(zip(actual, expected)):
            assert a.is_dir is False
            assert a.url == e[0]
            assert a.is_self == e[1]
Пример #2
0
def test_linker_iteration(fs_fac, page_path, expected):
    fs = fs_fac()
    with mock_fs_scope(fs):
        app = fs.getApp()
        app.config.set('site/pretty_urls', True)
        src = app.getSource('pages')
        linker = Linker(src, os.path.dirname(page_path),
                        root_page_path=page_path)
        actual = list(iter(linker))

        assert len(actual) == len(expected)
        for (a, e) in zip(actual, expected):
            is_dir, name, is_self, url = e
            assert a.is_dir == is_dir
            assert a.name == name
            assert a.is_self == is_self
            assert a.url == url
Пример #3
0
def _load_family(data, name):
    from piecrust.data.linker import Linker
    return Linker(data._page.source, data._page.content_item)