aboutsummaryrefslogtreecommitdiff
path: root/test/haketilo_test
diff options
context:
space:
mode:
Diffstat (limited to 'test/haketilo_test')
-rw-r--r--test/haketilo_test/unit/test_patterns_query_tree.py51
1 files changed, 18 insertions, 33 deletions
diff --git a/test/haketilo_test/unit/test_patterns_query_tree.py b/test/haketilo_test/unit/test_patterns_query_tree.py
index 80bf554..1660aa2 100644
--- a/test/haketilo_test/unit/test_patterns_query_tree.py
+++ b/test/haketilo_test/unit/test_patterns_query_tree.py
@@ -6,7 +6,7 @@ Haketilo unit tests - URL patterns
# This file is part of Haketilo
#
-# Copyright (C) 2021, Wojtek Kosior
+# Copyright (C) 2021, 2022 Wojtek Kosior <koszko@koszko.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the CC0 1.0 Universal License as published by
@@ -70,18 +70,11 @@ def test_modify_branch(execute_in_page):
returnval(branch);
}''')
assert branch == {
- 'literal_match': None,
- 'wildcard_matches': [None, None, None],
- 'children': {
+ 'c': {
'com': {
- 'literal_match': None,
- 'wildcard_matches': [None, None, None],
- 'children': {
+ 'c': {
'example': {
- 'literal_match': ['some_item'],
- 'wildcard_matches': [None, None, None],
- 'children': {
- }
+ 'l': ['some_item']
}
}
}
@@ -95,8 +88,8 @@ def test_modify_branch(execute_in_page):
returnval([branch, items_added]);
}''', branch)
assert items_added == 1
- assert branch['children']['com']['children']['example']['literal_match'] \
- == ['some_item', 'other_item']
+ assert branch['c']['com']['c']['example']['l'] \
+ == ['some_item', 'other_item']
for i in range(3):
for expected_array in [['third_item'], ['third_item', '4th_item']]:
@@ -110,10 +103,9 @@ def test_modify_branch(execute_in_page):
}''',
branch, wildcard, expected_array[-1])
assert items_added == 2
- sample = branch['children']['com']['children']['sample']
- assert sample['wildcard_matches'][i] == expected_array
- assert sample['children'][wildcard]['literal_match'] \
- == expected_array
+ sample = branch['c']['com']['c']['sample']
+ assert sample[wildcard] == expected_array
+ assert sample['c'][wildcard]['l'] == expected_array
branch, items_added = execute_in_page(
'''{
@@ -124,8 +116,8 @@ def test_modify_branch(execute_in_page):
}''',
branch)
assert items_added == 1
- assert branch['children']['org']['children']['koszko']['children']['***']\
- ['children']['123']['literal_match'] == ['5th_item']
+ assert branch['c']['org']['c']['koszko']['c']['***']['c']['123']['l'] \
+ == ['5th_item']
# Let's verify that removing a nonexistent element doesn't modify the tree.
branch2, items_removed = execute_in_page(
@@ -150,7 +142,7 @@ def test_modify_branch(execute_in_page):
}''',
branch)
assert items_removed == 1
- assert 'org' not in branch['children']
+ assert 'org' not in branch['c']
for i in range(3):
for expected_array in [['third_item'], None]:
@@ -166,11 +158,10 @@ def test_modify_branch(execute_in_page):
assert items_removed == 2
if i == 2 and expected_array == []:
break
- sample = branch['children']['com']['children'].get('sample', {})
- assert sample.get('wildcard_matches', [None, None, None])[i] \
+ sample = branch['c']['com']['c'].get('sample', {})
+ assert sample.get(wildcard) == expected_array
+ assert sample.get('c', {}).get(wildcard, {}).get('l') \
== expected_array
- assert sample.get('children', {}).get(wildcard, {})\
- .get('literal_match') == expected_array
for i in range(2):
branch, items_removed = execute_in_page(
@@ -182,15 +173,9 @@ def test_modify_branch(execute_in_page):
branch)
assert items_removed == 1
if i == 0:
- assert branch['children']['com']['children']['example']\
- ['literal_match'] == ['some_item']
- else:
- assert branch == {
- 'literal_match': None,
- 'wildcard_matches': [None, None, None],
- 'children': {
- }
- }
+ assert branch['c']['com']['c']['example']['l'] == ['some_item']
+
+ assert branch == {}
@pytest.mark.get_page('https://gotmyowndoma.in')
def test_search_branch(execute_in_page):