From e46cf6aa6b1d7fab79e54b27f390403af852ba1d Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 25 Jul 2023 14:30:24 -0700 Subject: [PATCH] fix unit test msg --- src/ytdl_sub/downloaders/url/validators.py | 8 +++++--- tests/unit/config/test_config_file.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ytdl_sub/downloaders/url/validators.py b/src/ytdl_sub/downloaders/url/validators.py index cd558e04..42f28ece 100644 --- a/src/ytdl_sub/downloaders/url/validators.py +++ b/src/ytdl_sub/downloaders/url/validators.py @@ -185,7 +185,7 @@ class MultiUrlValidator(OptionsValidator): Partially validate a collection """ if isinstance(value, dict): - value["urls"] = value.get("urls", [{"url": "placeholder"}]) + value["url"] = value.get("url", "sadfasdf") _ = cls(name, value) def __init__(self, name, value): @@ -197,9 +197,11 @@ class MultiUrlValidator(OptionsValidator): # Pop old required field in case it's still there value_copy.pop("download_strategy", None) - if "urls" in value: - self._urls = UrlListValidator(name=name, value=value["urls"]) + if "urls" in value_copy: + self._urls = UrlListValidator(name=name, value=value_copy["urls"]) else: + # Validate using a single URL validator first + _ = UrlValidator(name=name, value=value_copy) self._urls = UrlListValidator(name=name, value=[value_copy]) else: # Should error here. TODO: Add simplifications download here (string, list) diff --git a/tests/unit/config/test_config_file.py b/tests/unit/config/test_config_file.py index 24de3269..0edfbd08 100644 --- a/tests/unit/config/test_config_file.py +++ b/tests/unit/config/test_config_file.py @@ -98,7 +98,8 @@ class TestConfigFilePartiallyValidatesPresets: preset_dict={"download": {"download_strategy": "multi_url", "bad_key": "nope"}}, expected_error_message="Validation error in partial_preset.download: " "'partial_preset.download' contains the field 'bad_key' which is not allowed. " - "Allowed fields: urls", + "Allowed fields: download_reverse, playlist_thumbnails, source_thumbnails, url, " + "variables", ) @pytest.mark.parametrize(