|
@@ -49,6 +49,31 @@ class TestMeta(object): |
|
|
|
|
|
|
|
|
assert pages == sorted(expected, key=lambda f: File(f).kind) |
|
|
assert pages == sorted(expected, key=lambda f: File(f).kind) |
|
|
|
|
|
|
|
|
|
|
|
def test_walk_resources_sorted_reverse(self): |
|
|
|
|
|
s = Site(TEST_SITE) |
|
|
|
|
|
s.load() |
|
|
|
|
|
s.config.plugins = ['hyde.ext.sorter.SorterPlugin'] |
|
|
|
|
|
s.config.sorter = Expando(dict(kind=dict(attr='source_file.kind', reverse=True))) |
|
|
|
|
|
|
|
|
|
|
|
SorterPlugin(s).begin_site() |
|
|
|
|
|
|
|
|
|
|
|
assert hasattr(s.content, 'walk_resources_sorted_by_kind') |
|
|
|
|
|
expected = ["404.html", |
|
|
|
|
|
"about.html", |
|
|
|
|
|
"apple-touch-icon.png", |
|
|
|
|
|
"merry-christmas.html", |
|
|
|
|
|
"crossdomain.xml", |
|
|
|
|
|
"favicon.ico", |
|
|
|
|
|
"robots.txt", |
|
|
|
|
|
"site.css" |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
pages = [page.name for page in |
|
|
|
|
|
s.content.walk_resources_sorted_by_kind()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert pages == sorted(expected, key=lambda f: File(f).kind, reverse=True) |
|
|
|
|
|
|
|
|
def test_walk_resources_sorted_with_filters(self): |
|
|
def test_walk_resources_sorted_with_filters(self): |
|
|
s = Site(TEST_SITE) |
|
|
s = Site(TEST_SITE) |
|
|
cfg = """ |
|
|
cfg = """ |
|
@@ -73,6 +98,29 @@ class TestMeta(object): |
|
|
|
|
|
|
|
|
assert pages == sorted(expected) |
|
|
assert pages == sorted(expected) |
|
|
|
|
|
|
|
|
|
|
|
def test_walk_resources_sorted_default_is_processable(self): |
|
|
|
|
|
s = Site(TEST_SITE) |
|
|
|
|
|
cfg = """ |
|
|
|
|
|
plugins: |
|
|
|
|
|
- hyde.ext.sorter.SorterPlugin |
|
|
|
|
|
sorter: |
|
|
|
|
|
kind2: |
|
|
|
|
|
filters: |
|
|
|
|
|
source_file.kind: html |
|
|
|
|
|
""" |
|
|
|
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
|
|
|
s.load() |
|
|
|
|
|
p_404 = s.content.resource_from_relative_path('404.html') |
|
|
|
|
|
p_404.is_processable = False |
|
|
|
|
|
SorterPlugin(s).begin_site() |
|
|
|
|
|
|
|
|
|
|
|
assert hasattr(s.content, 'walk_resources_sorted_by_kind2') |
|
|
|
|
|
expected = ["about.html", "merry-christmas.html"] |
|
|
|
|
|
|
|
|
|
|
|
pages = [page.name for page in s.content.walk_resources_sorted_by_kind2()] |
|
|
|
|
|
|
|
|
|
|
|
assert pages == sorted(expected) |
|
|
|
|
|
|
|
|
def test_prev_next(self): |
|
|
def test_prev_next(self): |
|
|
s = Site(TEST_SITE) |
|
|
s = Site(TEST_SITE) |
|
|
cfg = """ |
|
|
cfg = """ |
|
|