-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_mkdocsoad.py
More file actions
57 lines (41 loc) · 1.35 KB
/
test_mkdocsoad.py
File metadata and controls
57 lines (41 loc) · 1.35 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import textwrap
from unittest.mock import Mock
import pytest
from neoteroi.mkdocs.oad import MkDocsOpenAPIDocumentationPlugin
from . import get_resource_file_path
def make_mock_page(src_dir="docs", src_path="index.md"):
mock_file = Mock()
mock_file.src_dir = src_dir
mock_file.src_path = src_path
mock_page = Mock()
mock_page.file = mock_file
return mock_page
def test_markdown_without_oad():
handler = MkDocsOpenAPIDocumentationPlugin()
example = textwrap.dedent(
"""
# Hello World!
Lorem ipsum dolor sit amet.
""".strip(
"\n"
)
)
result = handler.on_page_markdown(example, make_mock_page())
assert result == example
@pytest.mark.parametrize("file_name", ["swagger.json", "swagger.yaml"])
def test_markdown_with_oad(file_name):
file_path = get_resource_file_path(file_name)
handler = MkDocsOpenAPIDocumentationPlugin()
example = textwrap.dedent(
f"""
# Hello World!
[OAD({file_path})]
""".strip(
"\n"
)
)
result = handler.on_page_markdown(example, make_mock_page())
# Note: not testing the full output since this responsibility belongs to the
# essentials-openapi package
assert "This Markdown has been generated by essentials-openapi" in result
assert "# Swagger Petstore" in result