forked from jpsca/writeadoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli_build.py
More file actions
60 lines (49 loc) · 1.34 KB
/
Copy pathtest_cli_build.py
File metadata and controls
60 lines (49 loc) · 1.34 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
58
59
60
from unittest.mock import call
import pytest
from writeadoc.main import Docs
@pytest.fixture
def docs(tmp_root):
(tmp_root / "comp").mkdir()
(tmp_root / "comp" / "test.jx").write_text("<h2>{{ content }}</h2>")
(tmp_root / "content" / "test.md").write_text(
"""
---
title: Test Page
imports:
"Test": "test.jx"
---
<Test>This **is** a test</Test>
```
<Test />
<Test></Test>
```
""".strip()
)
docs = Docs(tmp_root, pages=["test.md"])
docs.catalog.add_folder(tmp_root / "comp")
return docs
def test_build_with_random_messages(mocker, docs):
mocker.patch(
"writeadoc.main.get_random_messages", return_value=["one", "two", "three"]
)
mock_print = mocker.patch("builtins.print")
docs.build()
assert mock_print.call_count == 5
mock_print.assert_has_calls([
call("one..."),
call("Processing pages..."),
call("two..."),
call("Rendering pages..."),
call("three..."),
])
def test_build_with_no_random_messages(mocker, docs):
mocker.patch(
"writeadoc.main.get_random_messages", return_value=["one", "two", "three"]
)
mock_print = mocker.patch("builtins.print")
docs.build(boring=True)
assert mock_print.call_count == 2
mock_print.assert_has_calls([
call("Processing pages..."),
call("Rendering pages..."),
])