fix case when provided trigger path is directory

If trigger is directory and we have permissions to read it, the loaded
will try to load this from it and will fail with IsADirectoryError
This commit is contained in:
2022-05-12 07:22:50 +03:00
parent f42c2c57fb
commit 04dcaa93ab
2 changed files with 18 additions and 2 deletions

View File

@ -58,6 +58,15 @@ def test_load_trigger_path(trigger_loader: TriggerLoader, resource_path_root: Pa
assert trigger_loader._load_trigger(f"{path}.ReportTrigger")
def test_load_trigger_path_directory(trigger_loader: TriggerLoader, resource_path_root: Path) -> None:
"""
must raise InvalidExtension if provided import path is directory
"""
path = resource_path_root.parent.parent / "src" / "ahriman" / "core" / "report"
with pytest.raises(InvalidExtension):
trigger_loader._load_trigger(f"{path}.ReportTrigger")
def test_load_trigger_path_not_found(trigger_loader: TriggerLoader) -> None:
"""
must raise InvalidExtension if file cannot be found