• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rdmorganiser / rdmo / 20170927153

12 Dec 2025 03:07PM UTC coverage: 94.814% (+0.02%) from 94.796%
20170927153

Pull #1427

github

web-flow
Merge 8c4e727d1 into 79917de8d
Pull Request #1427: RDMO 2.4.0 🎆

2124 of 2229 branches covered (95.29%)

22688 of 23929 relevant lines covered (94.81%)

3.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.77
rdmo/projects/tests/test_navigation.py
1
import pytest
4✔
2

3
from rdmo.projects.models import Project
4✔
4
from rdmo.projects.progress import compute_navigation
4✔
5

6
sections = (
4✔
7
    'http://example.com/terms/questions/catalog/individual',
8
    'http://example.com/terms/questions/catalog/collections',
9
    'http://example.com/terms/questions/catalog/set',
10
    'http://example.com/terms/questions/catalog/conditions',
11
    'http://example.com/terms/questions/catalog/blocks'
12
)
13

14
# (count, total, show) for each page or section (as default fallback)
15
result_map = {
4✔
16
    'http://example.com/terms/questions/catalog/individual': (8, 9),
17
    'http://example.com/terms/questions/catalog/individual/*': (1, 1, True),
18
    'http://example.com/terms/questions/catalog/individual/select_creatable': (0, 1, True),
19
    'http://example.com/terms/questions/catalog/collections': (9, 10),
20
    'http://example.com/terms/questions/catalog/collections/*': (1, 1, True),
21
    'http://example.com/terms/questions/catalog/collections/select_creatable': (0, 1, True),
22
    'http://example.com/terms/questions/catalog/set': (47, 57),
23
    'http://example.com/terms/questions/catalog/set/individual-single': (8, 9, True),
24
    'http://example.com/terms/questions/catalog/set/individual-collection': (9, 10, True),
25
    'http://example.com/terms/questions/catalog/set/collection-single': (14, 18, True),
26
    'http://example.com/terms/questions/catalog/set/collection-collection': (16, 20, True),
27
    'http://example.com/terms/questions/catalog/conditions': (7, 17),
28
    'http://example.com/terms/questions/catalog/conditions/input': (2, 2, True),
29
    'http://example.com/terms/questions/catalog/conditions/text_contains': (1, 1, True),
30
    'http://example.com/terms/questions/catalog/conditions/text_empty': (0, 0, False),
31
    'http://example.com/terms/questions/catalog/conditions/text_equal': (1, 1, True),
32
    'http://example.com/terms/questions/catalog/conditions/text_greater_than': (0, 0, False),
33
    'http://example.com/terms/questions/catalog/conditions/text_greater_than_equal': (0, 0, False),
34
    'http://example.com/terms/questions/catalog/conditions/text_lesser_than': (0, 0, False),
35
    'http://example.com/terms/questions/catalog/conditions/text_lesser_than_equal': (0, 0, False),
36
    'http://example.com/terms/questions/catalog/conditions/text_not_empty': (1, 1, True),
37
    'http://example.com/terms/questions/catalog/conditions/text_not_equal': (0, 0, False),
38
    'http://example.com/terms/questions/catalog/conditions/option_empty': (0, 0, False),
39
    'http://example.com/terms/questions/catalog/conditions/option_equal': (1, 1, True),
40
    'http://example.com/terms/questions/catalog/conditions/option_not_empty': (1, 1, True),
41
    'http://example.com/terms/questions/catalog/conditions/option_not_equal': (0, 0, False),
42
    'http://example.com/terms/questions/catalog/conditions/set': (0, 2, True),
43
    'http://example.com/terms/questions/catalog/conditions/set_set': (0, 2, True),
44
    'http://example.com/terms/questions/catalog/conditions/set_set_question': (0, 2, True),
45
    'http://example.com/terms/questions/catalog/conditions/optionset': (0, 2, True),
46
    'http://example.com/terms/questions/catalog/conditions/text_set': (0, 2, True),
47
    'http://example.com/terms/questions/catalog/blocks': (13, 29),
48
    'http://example.com/terms/questions/catalog/blocks/single': (0, 1, True),
49
    'http://example.com/terms/questions/catalog/blocks/collection': (0, 0, True),
50
    'http://example.com/terms/questions/catalog/blocks/two-collections': (0, 0, True),
51
    'http://example.com/terms/questions/catalog/blocks/set': (13, 27, True),
52
    'http://example.com/terms/questions/catalog/blocks/optional': (0, 1, True),
53
}
54

55

56
@pytest.mark.parametrize('section_uri', sections)
4✔
57
def test_compute_navigation(db, section_uri):
4✔
58
    project = Project.objects.get(id=1)
4✔
59
    project.catalog.prefetch_elements()
4✔
60

61
    section = project.catalog.sections.get(uri=section_uri)
4✔
62

63
    navigation = compute_navigation(project, section)
4✔
64
    assert [item['id'] for item in navigation] == [element.id for element in project.catalog.elements]
4✔
65

66
    for section in navigation:
4✔
67
        if section['uri'] in result_map:
4✔
68
            count, total = result_map[section['uri']]
4✔
69
            assert section['count'] == count, section['uri']
4✔
70
            assert section['total'] == total, section['uri']
4✔
71
            assert 'title' in section  # test for verbose
4✔
72

73
        if 'pages' in section:
4✔
74
            for page in section['pages']:
4✔
75
                uri = page['uri']
4✔
76
                wildcard_uri = section['uri'] + '/*'
4✔
77

78
                if uri in result_map:
4✔
79
                    count, total, show = result_map[uri]
4✔
80
                elif wildcard_uri in result_map:
4✔
81
                    count, total, show = result_map[wildcard_uri]
4✔
82
                else:
83
                    raise AssertionError('{uri} not in result_map'.format(**page))
×
84

85
                assert page['count'] == count, page['uri']
4✔
86
                assert page['total'] == total, page['uri']
4✔
87
                assert page['show'] == show, page['uri']
4✔
88
                assert 'title' in  page  # test for verbose, help is filtered out
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc