-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sort.py
More file actions
29 lines (20 loc) · 824 Bytes
/
Copy pathtest_sort.py
File metadata and controls
29 lines (20 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from cedarmapper.render.sort import SortSpec, parse_sort_spec
def test_parse_simple_keys():
s = parse_sort_spec("w")
assert s == [SortSpec(key="w", reverse=False)]
s = parse_sort_spec("-w")
assert s == [SortSpec(key="w", reverse=True)]
s = parse_sort_spec("wi")
assert s == [SortSpec(key="w", reverse=False), SortSpec(key="i", reverse=False)]
def test_parse_with_dashes_and_spaces():
s = parse_sort_spec("i-sd")
assert s == [
SortSpec(key="i", reverse=False),
SortSpec(key="s", reverse=True),
SortSpec(key="d", reverse=False),
]
s = parse_sort_spec(" -n p ")
assert s == [SortSpec(key="n", reverse=True), SortSpec(key="p", reverse=False)]
def test_parse_empty_or_none():
assert parse_sort_spec("") == []
assert parse_sort_spec(" ") == []