[BUGFIX] Fix overrides failing validation in datetime vars (#209)
This commit is contained in:
parent
2f4a2a4726
commit
3e801c56eb
2 changed files with 19 additions and 1 deletions
|
|
@ -22,7 +22,7 @@ class StringDatetimeValidator(OverridesStringFormatterValidator):
|
|||
def apply_formatter(self, variable_dict: Dict[str, str]) -> str:
|
||||
output = super().apply_formatter(variable_dict)
|
||||
try:
|
||||
_ = datetime_from_str(self._value)
|
||||
_ = datetime_from_str(output)
|
||||
except Exception as exc:
|
||||
raise self._validation_exception(f"Invalid datetime string: {str(exc)}")
|
||||
return output
|
||||
|
|
|
|||
|
|
@ -135,6 +135,24 @@ class TestPreset:
|
|||
"key-3": "this-preset",
|
||||
}
|
||||
|
||||
def test_preset_datetime_with_override(self, config_file, youtube_video, output_options):
|
||||
preset = Preset(
|
||||
config=config_file,
|
||||
name="test",
|
||||
value={
|
||||
"youtube": youtube_video,
|
||||
"output_options": dict(
|
||||
output_options,
|
||||
**{"maintain_download_archive": True, "keep_files_after": "today-{ttl}"}
|
||||
),
|
||||
"overrides": {"ttl": "2months"},
|
||||
},
|
||||
)
|
||||
assert (
|
||||
preset.overrides.apply_formatter(formatter=preset.output_options.keep_files_after)
|
||||
== "today-2months"
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"parent_preset", ["preset_self_loop", "preset_loop_0", "preset_loop_1"]
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue