Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jul 4, 2024
1 parent d3a2c29 commit 2d5e230
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions rdmo/projects/tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@

# (count, total, show) for each page or section (as default fallback)
result_map = {
'http://example.com/terms/questions/catalog/individual': (1, 1, True),
'http://example.com/terms/questions/catalog/individual': (8, 9),
'http://example.com/terms/questions/catalog/individual/*': (1, 1, True),
'http://example.com/terms/questions/catalog/individual/autocomplete': (0, 1, True),
'http://example.com/terms/questions/catalog/collections': (1, 1, True),
'http://example.com/terms/questions/catalog/collections': (9, 10),
'http://example.com/terms/questions/catalog/collections/*': (1, 1, True),
'http://example.com/terms/questions/catalog/collections/autocomplete': (0, 1, True),
'http://example.com/terms/questions/catalog/set': (47, 57),
'http://example.com/terms/questions/catalog/set/individual-single': (8, 9, True),
'http://example.com/terms/questions/catalog/set/individual-collection': (9, 10, True),
'http://example.com/terms/questions/catalog/set/collection-single': (14, 18, True),
'http://example.com/terms/questions/catalog/set/collection-collection': (16, 20, True),
'http://example.com/terms/questions/catalog/conditions': (15, 23),
'http://example.com/terms/questions/catalog/conditions/input': (2, 2, True),
'http://example.com/terms/questions/catalog/conditions/text_contains': (1, 1, True),
'http://example.com/terms/questions/catalog/conditions/text_empty': (1, 1, False),
Expand All @@ -39,6 +43,7 @@
'http://example.com/terms/questions/catalog/conditions/set_set': (0, 2, True),
'http://example.com/terms/questions/catalog/conditions/optionset': (0, 2, True),
'http://example.com/terms/questions/catalog/conditions/text_set': (0, 2, True),
'http://example.com/terms/questions/catalog/blocks': (9, 12),
'http://example.com/terms/questions/catalog/blocks/set': (9, 12, True),
}

Expand All @@ -54,14 +59,23 @@ def test_compute_navigation(db, section_uri):
assert [item['id'] for item in navigation] == [element.id for element in project.catalog.elements]

for section in navigation:
if section['uri'] in result_map:
count, total = result_map[section['uri']]
assert section['count'] == count, section['uri']
assert section['total'] == total, section['uri']

if 'pages' in section:
for page in section['pages']:
if page['uri'] in result_map:
count, total, show = result_map[page['uri']]
elif section['uri'] in result_map:
count, total, show = result_map[section['uri']]
uri = page['uri']
wildcard_uri = section['uri'] + '/*'

if uri in result_map:
count, total, show = result_map[uri]
elif wildcard_uri in result_map:
count, total, show = result_map[wildcard_uri]
else:
raise AssertionError('{uri} not in result_map'.format(**page))

assert page['count'] == count, page['uri']
assert page['total'] == total, page['uri']
assert page['show'] == show, page['uri']

0 comments on commit 2d5e230

Please sign in to comment.