-
Notifications
You must be signed in to change notification settings - Fork 51
/
test_mongodb_domain.py
110 lines (96 loc) · 4.64 KB
/
test_mongodb_domain.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from pathlib import Path
import pytest
from . import n
from .n import FileId
from .parser import Project
from .test_project import Backend
from .types import BuildIdentifierSet
from .util_test import check_ast_testing_string
@pytest.fixture
def backend() -> Backend:
backend = Backend()
build_identifiers: BuildIdentifierSet = {}
project = Project(Path("test_data/test_mongodb_domain"), backend, build_identifiers)
project.build()
return backend
# Test all directives exclusive to the mongodb domain
def test_mongodb_directives(backend: Backend) -> None:
page_id = FileId("index.txt")
page = backend.pages[page_id]
assert len(page.static_assets) == 1
ast = page.ast
section = ast.children[0]
assert isinstance(section, n.Section)
introduction = section.children[1]
check_ast_testing_string(
introduction,
"""<directive domain="mongodb" name="introduction">
<paragraph><text>
This test project tests directives exclusive to the mongodb domain, which is used for mongodb-specific directives.
</text></paragraph>
</directive>""",
)
button = section.children[2]
check_ast_testing_string(
button,
"""<directive domain="mongodb" name="button" uri="/path/to/download">
<text>Button text</text></directive>""",
)
card_group = section.children[3]
assert isinstance(card_group, n.Parent)
assert len(card_group.children) == 3
check_ast_testing_string(
card_group,
"""<directive domain="mongodb" name="card-group" columns="3" style="compact" layout="carousel">
<directive domain="mongodb" name="card" headline="Run a self-managed database" cta="Get started with MongoDB" url="http://mongodb.com" icon="/images/pink.png" icon-alt="Alt text" tag="server" checksum="71bf03ab0c5b8d46f0c03b77db6bd18a77d984d216c62c3519dfb45c162cd86b" width="360.0" height="360.0">
<paragraph><text>Download and install the MongoDB database on your own\ninfrastructure.</text></paragraph>
</directive>
<directive domain="mongodb" name="card" cta="Call to action" url="https://www.url.com" icon="/images/pink.png" width="360.0" height="360.0" icon-alt="Alt text" checksum="71bf03ab0c5b8d46f0c03b77db6bd18a77d984d216c62c3519dfb45c162cd86b">
<paragraph><text>Paragraph.</text></paragraph>
</directive>
<directive domain="mongodb" name="card" cta="Call to action" url="https://www.url.com" icon="/images/pink.png" width="360.0" height="360.0" icon-alt="Alt text" checksum="71bf03ab0c5b8d46f0c03b77db6bd18a77d984d216c62c3519dfb45c162cd86b">
<paragraph><text>Paragraph.</text></paragraph>
</directive>
</directive>""",
)
kicker = section.children[4]
check_ast_testing_string(
kicker,
"""<directive domain="mongodb" name="kicker"><text>A kicker is a subheader above a main header</text></directive>""",
)
procedure = section.children[5]
check_ast_testing_string(
procedure,
"""
<directive domain="mongodb" name="procedure">
<directive domain="mongodb" name="step">
<text>Connect to Your Deployment</text>
<section>
<heading id="connect-to-your-deployment"><text>Connect to Your Deployment</text></heading>
<paragraph><text>Paragraph.</text></paragraph>
<paragraph>
<ref_role domain="std" name="label" target="Connect to MongoDB">
<text>To learn more, see Connect to MongoDB</text>
</ref_role>
</paragraph>
</section>
</directive>
<directive domain="mongodb" name="step">
<text>Import Your Data</text>
<section>
<heading id="import-your-data"><text>Import Your Data</text></heading>
<paragraph><text>Paragraph.</text></paragraph>
<paragraph>
<ref_role domain="std" name="label" target="Import and Export Data">
<text>To learn more, see Import and Export Data</text>
</ref_role>
</paragraph>
</section>
</directive>
</directive>""",
)
cta = section.children[6]
check_ast_testing_string(
cta,
"""<directive domain="mongodb" name="cta"><paragraph><reference refuri="https://www.mongodb.com/docs/manual/introduction/"><text>Read the Introduction to MongoDB</text></reference></paragraph></directive>""",
)