Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: handle empty-str publish-debug #900

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sphinxcontrib/confluencebuilder/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ def apply_defaults(builder):

# ensure confluence_publish_debug is set with its expected enum value
publish_debug = conf.confluence_publish_debug
if publish_debug is not None and publish_debug is not False:
if not isinstance(publish_debug, PublishDebug):
# a boolean-provided publish debug is deprecated, but we will accept
# it as its original implementation as an indication to enable
# urllib3 logs
if publish_debug is True:
conf.confluence_publish_debug = PublishDebug.urllib3
elif not isinstance(publish_debug, PublishDebug):
elif isinstance(publish_debug, str) and publish_debug:
conf.confluence_publish_debug = PublishDebug[publish_debug.lower()]
else:
conf.confluence_publish_debug = PublishDebug.none
else:
conf.confluence_publish_debug = PublishDebug.none

if conf.confluence_publish_intersphinx is None:
conf.confluence_publish_intersphinx = True
Expand Down
19 changes: 19 additions & 0 deletions tests/unit-tests/test_config_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,25 @@ def test_config_check_publish(self):
with self.assertRaises(ConfluenceConfigError):
self._try_config()

def test_config_check_publish_debug(self):
self.config['confluence_publish_debug'] = ''
self._try_config()

self.config['confluence_publish_debug'] = 'urllib3'
self._try_config()

self.config['confluence_publish_debug'] = 'unknown-entry'
with self.assertRaises(ConfluenceConfigError):
self._try_config()

self.config['confluence_publish_debug'] = [1, 2, 3]
with self.assertRaises(ConfluenceConfigError):
self._try_config()

self.config['confluence_publish_debug'] = True
with self.assertRaises(SphinxWarning):
self._try_config()

def test_config_check_publish_delay(self):
self.config['confluence_publish_delay'] = 0.3
self._try_config()
Expand Down