32 行
1 KiB
Python
32 行
1 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from services.settings import PluginSettings
|
|
|
|
|
|
class SettingsTest(unittest.TestCase):
|
|
def test_invalid_numbers_fall_back_to_defaults(self) -> None:
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
settings = PluginSettings.from_config(
|
|
{
|
|
"archive_format": "invalid",
|
|
"pdf_chunk_size": "bad",
|
|
"download_timeout_seconds": "bad",
|
|
"jm_batch_count": "bad",
|
|
"komga": {"scan_timeout_seconds": "bad"},
|
|
},
|
|
Path(temp_dir),
|
|
)
|
|
|
|
self.assertEqual(settings.archive_format, "cbz")
|
|
self.assertEqual(settings.pdf_chunk_size, 80)
|
|
self.assertEqual(settings.download_timeout_seconds, 3600)
|
|
self.assertEqual(settings.jm_batch_count, 20)
|
|
self.assertEqual(settings.komga.scan_timeout_seconds, 30)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|