Skip to content

Commit cedec12

Browse files
committed
Add test for link check nox session
1 parent b271483 commit cedec12

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/unit/nox/_documentation_test.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from exasol.toolbox.nox._documentation import (
1111
_docs_links_check,
12+
docs_links_check,
1213
docs_list_links,
1314
)
1415
from noxconfig import PROJECT_CONFIG
@@ -27,7 +28,7 @@ def index(config):
2728
:maxdepth: 1
2829
:hidden:
2930
30-
file
31+
dummy
3132
"""
3233
index_rst.write_text(text)
3334

@@ -102,3 +103,23 @@ def test_docs_links_check(config, index, file_content, expected_code, expected_m
102103

103104
assert code == expected_code
104105
assert expected_message in message
106+
107+
108+
class TestDocsLinksCheck:
109+
@staticmethod
110+
def test_works_as_expected_for_good_link(nox_session, config):
111+
with patch("exasol.toolbox.nox._documentation.PROJECT_CONFIG", new=config):
112+
with patch("exasol.toolbox.nox._documentation._docs_links_check") as mock:
113+
mock.return_value = (0, "")
114+
docs_links_check(nox_session)
115+
116+
@staticmethod
117+
def test_raises_exception_for_problem_returned(nox_session, config, capsys):
118+
with patch("exasol.toolbox.nox._documentation.PROJECT_CONFIG", new=config):
119+
with patch("exasol.toolbox.nox._documentation._docs_links_check") as mock:
120+
mock.return_value = (0, "[broken] ....")
121+
122+
with pytest.raises(_SessionQuit):
123+
docs_links_check(nox_session)
124+
125+
assert capsys.readouterr().out == "\x1b[31merrors:\n[broken] ....\n"

0 commit comments

Comments
 (0)