Skip to content

Commit 8dcda79

Browse files
committed
tests: remove validations now that title not mandatory
1 parent 3b34042 commit 8dcda79

File tree

1 file changed

+51
-37
lines changed

1 file changed

+51
-37
lines changed

quartodoc/tests/test_validation.py

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,79 @@
1-
import pytest, copy
1+
import copy
2+
import pytest
3+
24
from quartodoc.autosummary import Builder
35

46
EXAMPLE_SECTIONS = [
5-
{'title': 'Preperation Functions',
6-
'desc': 'Functions that fetch objects.\nThey prepare a representation of the site.\n',
7-
'contents': ['Auto', 'blueprint', 'collect', 'get_object', 'preview']},
8-
{'title': 'Docstring Renderers',
9-
'desc': 'Renderers convert parsed docstrings into a target format, like markdown.\n',
10-
'contents': [{'name': 'MdRenderer', 'children': 'linked'},
11-
{'name': 'MdRenderer.render', 'dynamic': True},
12-
{'name': 'MdRenderer.render_annotation', 'dynamic': True},
13-
{'name': 'MdRenderer.render_header', 'dynamic': True}]
14-
},
15-
{'title': 'API Builders',
16-
'desc': 'Builders build documentation. They tie all the pieces\nof quartodoc together.\n',
17-
'contents': [{'kind': 'auto', 'name': 'Builder', 'members': []},
18-
'Builder.from_quarto_config', 'Builder.build', 'Builder.write_index']
19-
},
20-
]
7+
{
8+
"title": "Preperation Functions",
9+
"desc": "Functions that fetch objects.\nThey prepare a representation of the site.\n",
10+
"contents": ["Auto", "blueprint", "collect", "get_object", "preview"],
11+
},
12+
{
13+
"title": "Docstring Renderers",
14+
"desc": "Renderers convert parsed docstrings into a target format, like markdown.\n",
15+
"contents": [
16+
{"name": "MdRenderer", "children": "linked"},
17+
{"name": "MdRenderer.render", "dynamic": True},
18+
{"name": "MdRenderer.render_annotation", "dynamic": True},
19+
{"name": "MdRenderer.render_header", "dynamic": True},
20+
],
21+
},
22+
{
23+
"title": "API Builders",
24+
"desc": "Builders build documentation. They tie all the pieces\nof quartodoc together.\n",
25+
"contents": [
26+
{"kind": "auto", "name": "Builder", "members": []},
27+
"Builder.from_quarto_config",
28+
"Builder.build",
29+
"Builder.write_index",
30+
],
31+
},
32+
]
33+
2134

2235
@pytest.fixture
2336
def sections():
2437
return copy.deepcopy(EXAMPLE_SECTIONS)
2538

39+
2640
def check_ValueError(sections):
2741
"Check that a ValueError is raised when creating a `Builder` instance. Return the error message as a string."
2842
with pytest.raises(ValueError) as e:
29-
Builder(sections=sections, package='quartodoc')
43+
Builder(sections=sections, package="quartodoc")
3044
return str(e.value)
3145

46+
3247
def test_valid_yaml(sections):
3348
"Test that valid YAML passes validation"
34-
Builder(sections=sections, package='quartodoc')
49+
Builder(sections=sections, package="quartodoc")
3550

36-
def test_missing_title(sections):
37-
"Test that missing title raises an error"
38-
del sections[0]['title']
39-
msg = check_ValueError(sections)
40-
assert '- Missing field `title` for element 0 in the list for `sections`' in msg
41-
42-
def test_missing_desc(sections):
43-
"Test that a missing description raises an error"
44-
sections = copy.deepcopy(EXAMPLE_SECTIONS)
45-
del sections[2]['desc']
46-
msg = check_ValueError(sections)
47-
assert '- Missing field `desc` for element 2 in the list for `sections`' in msg
4851

4952
def test_missing_name_contents_1(sections):
5053
"Test that a missing name in contents raises an error"
51-
del sections[2]['contents'][0]['name']
54+
del sections[2]["contents"][0]["name"]
5255
msg = check_ValueError(sections)
53-
assert '- Missing field `name` for element 0 in the list for `contents` located in element 2 in the list for `sections`' in msg
56+
assert (
57+
"- Missing field `name` for element 0 in the list for `contents` located in element 2 in the list for `sections`"
58+
in msg
59+
)
60+
5461

5562
def test_missing_name_contents_2(sections):
5663
"Test that a missing name in contents raises an error in a different section."
57-
del sections[1]['contents'][0]['name']
64+
del sections[1]["contents"][0]["name"]
5865
msg = check_ValueError(sections)
59-
assert '- Missing field `name` for element 0 in the list for `contents` located in element 1 in the list for `sections`' in msg
66+
assert (
67+
"- Missing field `name` for element 0 in the list for `contents` located in element 1 in the list for `sections`"
68+
in msg
69+
)
70+
6071

6172
def test_misplaced_kindpage(sections):
6273
"Test that a misplaced kind: page raises an error"
63-
sections[0]['kind'] = 'page'
74+
sections[0]["kind"] = "page"
6475
msg = check_ValueError(sections)
65-
assert ' - Missing field `path` for element 0 in the list for `sections`, which you need when setting `kind: page`.' in msg
76+
assert (
77+
" - Missing field `path` for element 0 in the list for `sections`, which you need when setting `kind: page`."
78+
in msg
79+
)

0 commit comments

Comments
 (0)