mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 06:56:18 -05:00
Marking archives_downloader config as imported when it is imported.
This commit is contained in:
parent
774090fc0a
commit
80decbd560
2 changed files with 16 additions and 2 deletions
|
|
@ -259,6 +259,10 @@ class ArchiveDownloaderConfig(ConfigFile):
|
|||
def file_name_format(self) -> str:
|
||||
return self._config['file_name_format']
|
||||
|
||||
def import_config(self, file: pathlib.Path = None, send_events=False):
|
||||
super().import_config(file, send_events)
|
||||
self.successful_import = True
|
||||
|
||||
|
||||
# Global instance for archive downloader config
|
||||
ARCHIVE_DOWNLOADER_CONFIG: ArchiveDownloaderConfig = ArchiveDownloaderConfig()
|
||||
|
|
|
|||
|
|
@ -1260,14 +1260,24 @@ async def test_archive_download_explicit_destination_overrides_domain_collection
|
|||
f"Archive should NOT be in collection directory {collection_dir}"
|
||||
|
||||
|
||||
def test_archive_downloader_config(test_directory):
|
||||
"""ArchiveDownloaderConfig loads and provides file_name_format."""
|
||||
@pytest.mark.asyncio
|
||||
async def test_archive_downloader_config_import(test_directory, async_client):
|
||||
"""ArchiveDownloaderConfig imports successfully and provides correct defaults."""
|
||||
config = get_archive_downloader_config()
|
||||
|
||||
# Default format should contain %(title)s
|
||||
assert '%(title)s' in config.file_name_format
|
||||
assert config.file_name_format == '%(download_datetime)s_%(title)s'
|
||||
|
||||
# Create a valid config file
|
||||
config_path = config.get_file()
|
||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
config_path.write_text('version: 0\nfile_name_format: "%(download_datetime)s_%(title)s"\n')
|
||||
|
||||
# Import should succeed and set successful_import
|
||||
config.import_config()
|
||||
assert config.successful_import is True
|
||||
|
||||
|
||||
def test_archive_downloader_config_validation():
|
||||
"""ArchiveDownloaderConfig validator rejects invalid formats."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue