|
@@ -31,7 +31,7 @@ class TestSorter(object): |
|
|
s = Site(TEST_SITE) |
|
|
s = Site(TEST_SITE) |
|
|
s.load() |
|
|
s.load() |
|
|
s.config.plugins = ['hyde.ext.sorter.SorterPlugin'] |
|
|
s.config.plugins = ['hyde.ext.sorter.SorterPlugin'] |
|
|
s.config.sorter = Expando(dict(kind=dict(attr='source_file.kind'))) |
|
|
|
|
|
|
|
|
s.config.sorter = Expando(dict(kind=dict(attr=['source_file.kind', 'name']))) |
|
|
|
|
|
|
|
|
SorterPlugin(s).begin_site() |
|
|
SorterPlugin(s).begin_site() |
|
|
|
|
|
|
|
@@ -49,13 +49,13 @@ class TestSorter(object): |
|
|
pages = [page.name for page in |
|
|
pages = [page.name for page in |
|
|
s.content.walk_resources_sorted_by_kind()] |
|
|
s.content.walk_resources_sorted_by_kind()] |
|
|
|
|
|
|
|
|
assert pages == sorted(sorted(expected), key=lambda f: File(f).kind) |
|
|
|
|
|
|
|
|
assert pages == sorted(expected, key=lambda f: (File(f).kind, f)) |
|
|
|
|
|
|
|
|
def test_walk_resources_sorted_reverse(self): |
|
|
def test_walk_resources_sorted_reverse(self): |
|
|
s = Site(TEST_SITE) |
|
|
s = Site(TEST_SITE) |
|
|
s.load() |
|
|
s.load() |
|
|
s.config.plugins = ['hyde.ext.sorter.SorterPlugin'] |
|
|
s.config.plugins = ['hyde.ext.sorter.SorterPlugin'] |
|
|
s.config.sorter = Expando(dict(kind=dict(attr='source_file.kind', reverse=True))) |
|
|
|
|
|
|
|
|
s.config.sorter = Expando(dict(kind=dict(attr=['source_file.kind', 'name'], reverse=True))) |
|
|
|
|
|
|
|
|
SorterPlugin(s).begin_site() |
|
|
SorterPlugin(s).begin_site() |
|
|
|
|
|
|
|
@@ -74,7 +74,7 @@ class TestSorter(object): |
|
|
s.content.walk_resources_sorted_by_kind()] |
|
|
s.content.walk_resources_sorted_by_kind()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert pages == sorted(sorted(expected), key=lambda f: File(f).kind, reverse=True) |
|
|
|
|
|
|
|
|
assert pages == sorted(expected, key=lambda f: (File(f).kind, f), 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) |
|
@@ -110,6 +110,7 @@ class TestSorter(object): |
|
|
attr: |
|
|
attr: |
|
|
- source_file.kind |
|
|
- source_file.kind |
|
|
- node.name |
|
|
- node.name |
|
|
|
|
|
- name |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
@@ -131,10 +132,10 @@ class TestSorter(object): |
|
|
|
|
|
|
|
|
expected_sorted = [File(page).name |
|
|
expected_sorted = [File(page).name |
|
|
for page in |
|
|
for page in |
|
|
sorted(sorted(expected), |
|
|
|
|
|
|
|
|
sorted(expected, |
|
|
key=lambda p: tuple( |
|
|
key=lambda p: tuple( |
|
|
[File(p).kind, |
|
|
[File(p).kind, |
|
|
File(p).parent.name]))] |
|
|
|
|
|
|
|
|
File(p).parent.name, p]))] |
|
|
assert pages == expected_sorted |
|
|
assert pages == expected_sorted |
|
|
|
|
|
|
|
|
def test_walk_resources_sorted_no_default_is_processable(self): |
|
|
def test_walk_resources_sorted_no_default_is_processable(self): |
|
@@ -146,6 +147,8 @@ class TestSorter(object): |
|
|
kind2: |
|
|
kind2: |
|
|
filters: |
|
|
filters: |
|
|
source_file.kind: html |
|
|
source_file.kind: html |
|
|
|
|
|
attr: |
|
|
|
|
|
- name |
|
|
""" |
|
|
""" |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
s.load() |
|
|
s.load() |
|
@@ -169,6 +172,8 @@ class TestSorter(object): |
|
|
kind2: |
|
|
kind2: |
|
|
filters: |
|
|
filters: |
|
|
source_file.kind: html |
|
|
source_file.kind: html |
|
|
|
|
|
attr: |
|
|
|
|
|
- name |
|
|
""" |
|
|
""" |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
s.config = Config(TEST_SITE, config_dict=yaml.load(cfg)) |
|
|
s.load() |
|
|
s.load() |
|
@@ -201,7 +206,8 @@ class TestSorter(object): |
|
|
- hyde.ext.sorter.SorterPlugin |
|
|
- hyde.ext.sorter.SorterPlugin |
|
|
sorter: |
|
|
sorter: |
|
|
folder_name: |
|
|
folder_name: |
|
|
attr: node.name |
|
|
|
|
|
|
|
|
attr: |
|
|
|
|
|
- node.name |
|
|
reverse: True |
|
|
reverse: True |
|
|
filters: |
|
|
filters: |
|
|
source_file.kind: html |
|
|
source_file.kind: html |
|
|