Files
shelfmark/tests/config/test_general_settings.py
T
splitsec2 ea69db3f8e feat(library): Audiobookshelf library check, and the sync fails closed when a library cannot be read (#1519)
Adds an Audiobookshelf provider for the library check, next to the Calibre one. It reads the server over its REST API (title, author, ISBN and ASIN per item), answers for audiobooks, and has its settings in General with a test button that uses the unsaved form values. Read only.

The Hardcover sync and automatic downloads now fail closed when an enabled library cannot be read: the sync skips its cycle and an automatic download holds the request. A library that listed items at the last index and now lists none counts as a failed read. Badges still fail open.
2026-10-23 00:21:40 -06:00

42 lines
1.6 KiB
Python

"""Tests for general settings definitions."""
from shelfmark.config.settings import general_settings
from shelfmark.core import settings_registry
def test_supported_formats_stay_admin_only():
"""The format lists describe the library, not a reader, so they are not overridable."""
fields = {field.key: field for field in general_settings() if hasattr(field, "key")}
assert fields["SUPPORTED_FORMATS"].user_overridable is False
assert fields["SUPPORTED_AUDIOBOOK_FORMATS"].user_overridable is False
def _fields():
return {field.key: field for field in general_settings() if hasattr(field, "key")}
def test_the_audiobookshelf_library_check_is_off_by_default():
fields = _fields()
assert fields["LIBRARY_CHECK_AUDIOBOOKSHELF_ENABLED"].default is False
assert fields["AUDIOBOOKSHELF_URL"].placeholder
assert fields["AUDIOBOOKSHELF_TOKEN"].key == "AUDIOBOOKSHELF_TOKEN"
assert fields["test_audiobookshelf_library"].callback is not None
def test_the_audiobookshelf_test_button_checks_the_unsaved_form_values(monkeypatch):
seen = {}
def _fake_test_connection(provider_name, current_values):
seen["call"] = (provider_name, current_values)
return {"success": True, "message": "Connected. Indexed 3 library item(s)."}
monkeypatch.setattr("shelfmark.core.library_index.test_connection", _fake_test_connection)
form = {"AUDIOBOOKSHELF_URL": "http://abs:13378", "AUDIOBOOKSHELF_TOKEN": "t"}
result = settings_registry.execute_action("general", "test_audiobookshelf_library", form)
assert result["success"] is True
assert seen["call"] == ("audiobookshelf", form)