|
1 | 1 | import shutil |
2 | 2 | from unittest.mock import ( |
3 | 3 | MagicMock, |
| 4 | + patch, |
4 | 5 | ) |
5 | 6 |
|
6 | 7 | import pytest |
| 8 | +from nox.sessions import _SessionQuit |
7 | 9 |
|
8 | 10 | from exasol.toolbox.nox._documentation import ( |
9 | 11 | _docs_links_check, |
10 | | - _docs_list_links, |
| 12 | + docs_list_links, |
11 | 13 | ) |
12 | 14 | from noxconfig import PROJECT_CONFIG |
13 | 15 |
|
@@ -48,11 +50,24 @@ def set_up_doc_with_link(config, index): |
48 | 50 | dummy_rst.write_text("https://examle.invalid\n:ref:`Test`") |
49 | 51 |
|
50 | 52 |
|
51 | | -def test_docs_links(config, set_up_doc_with_link): |
52 | | - r_code, text = _docs_list_links(config.documentation_path) |
53 | | - |
54 | | - assert not r_code |
55 | | - assert text == """filename: dummy.rst:1 -> uri: https://examle.invalid""" |
| 53 | +class TestDocsListLinks: |
| 54 | + @staticmethod |
| 55 | + def test_works_as_expected(nox_session, config, set_up_doc_with_link, capsys): |
| 56 | + with patch("exasol.toolbox.nox._documentation.PROJECT_CONFIG", new=config): |
| 57 | + docs_list_links(nox_session) |
| 58 | + assert ( |
| 59 | + capsys.readouterr().out |
| 60 | + == "filename: dummy.rst:1 -> uri: https://examle.invalid\n" |
| 61 | + ) |
| 62 | + |
| 63 | + @staticmethod |
| 64 | + def test_raises_error_for_rcode_not_0(nox_session, config): |
| 65 | + with patch("exasol.toolbox.nox._documentation.PROJECT_CONFIG", new=config): |
| 66 | + with patch("exasol.toolbox.nox._documentation._docs_list_links") as mock: |
| 67 | + mock.return_value = (1, "dummy_text") |
| 68 | + |
| 69 | + with pytest.raises(_SessionQuit): |
| 70 | + docs_list_links(nox_session) |
56 | 71 |
|
57 | 72 |
|
58 | 73 | @pytest.mark.parametrize( |
|
0 commit comments