summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonas Haag <jonas@lophus.org>2019-11-13 15:39:47 +0100
committerJonas Haag <jonas.haag@jda.com>2019-11-25 09:53:45 +0100
commitdf2f80c7553714397d5ee09b43025e0df9eefa4a (patch)
treefa14b5147d24b2954f69cea0a6f98c10e6ef1c93 /tests
parent125179e76e76f5629138a945b026262916cfaaef (diff)
downloadsphinx-git-df2f80c7553714397d5ee09b43025e0df9eefa4a.tar.gz
Add linkcheck_auth option
Diffstat (limited to 'tests')
-rw-r--r--tests/test_build_linkcheck.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py
index 4bf47a962..22866b27b 100644
--- a/tests/test_build_linkcheck.py
+++ b/tests/test_build_linkcheck.py
@@ -8,6 +8,7 @@
:license: BSD, see LICENSE for details.
"""
+from unittest import mock
import pytest
@@ -47,3 +48,25 @@ def test_anchors_ignored(app, status, warning):
# expect all ok when excluding #top
assert not content
+
+
+@pytest.mark.sphinx(
+ 'linkcheck', testroot='linkcheck', freshenv=True,
+ confoverrides={'linkcheck_auth': [
+ (r'.+google\.com/image.+', 'authinfo1'),
+ (r'.+google\.com.+', 'authinfo2'),
+ ]
+ })
+def test_auth(app, status, warning):
+ mock_req = mock.MagicMock()
+ mock_req.return_value = 'fake-response'
+
+ with mock.patch.multiple('requests', get=mock_req, head=mock_req):
+ app.builder.build_all()
+ for c_args, c_kwargs in mock_req.call_args_list:
+ if 'google.com/image' in c_args[0]:
+ assert c_kwargs['auth'] == 'authinfo1'
+ elif 'google.com' in c_args[0]:
+ assert c_kwargs['auth'] == 'authinfo2'
+ else:
+ assert not c_kwargs['auth']