server/tags: fix tag sorting

Brainfart from d6942121e5
This commit is contained in:
rr- 2016-08-14 17:54:15 +02:00
parent 023ec9a976
commit ef4af697c4
2 changed files with 5 additions and 5 deletions

View file

@ -63,7 +63,7 @@ def sort_tags(tags):
return sorted(
tags,
key=lambda tag: (
default_category_name != tag.category.name,
default_category_name == tag.category.name,
tag.category.name,
tag.names[0].name)
)

View file

@ -19,10 +19,10 @@ def _assert_tag_siblings(result, expected_names_and_occurrences):
@pytest.mark.parametrize('input,expected_tag_names', [
([('a', 'a', True), ('b', 'b', False), ('c', 'c', False)], list('abc')),
([('c', 'a', True), ('b', 'b', False), ('a', 'c', False)], list('cba')),
([('a', 'c', True), ('b', 'b', False), ('c', 'a', False)], list('acb')),
([('a', 'c', False), ('b', 'b', False), ('c', 'a', True)], list('cba')),
([('a', 'a', True), ('b', 'b', False), ('c', 'c', False)], list('bca')),
([('c', 'a', True), ('b', 'b', False), ('a', 'c', False)], list('bac')),
([('a', 'c', True), ('b', 'b', False), ('c', 'a', False)], list('cba')),
([('a', 'c', False), ('b', 'b', False), ('c', 'a', True)], list('bac')),
])
def test_sort_tags(
input, expected_tag_names, tag_factory, tag_category_factory):