Skip to content

Commit

Permalink
Tests: validate addon folder before installing
Browse files Browse the repository at this point in the history
  • Loading branch information
oakkitten committed May 3, 2022
1 parent 19f6865 commit 4123853
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/tools/testing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
from contextlib import contextmanager
from pathlib import Path

import anki.collection
import aqt.operations.note
Expand Down Expand Up @@ -55,6 +56,14 @@ def reset_addon_configuration(addon_name: str):


def add_addon_to_copy_into_anki_addons_folder(addon_name: str, addon_folder: str):
addon_folder = Path(addon_folder).resolve()

if not addon_folder.exists() or not addon_folder.is_dir():
raise Exception(f"Addon folder {addon_folder} is not a directory")

if (addon_folder / "meta.json").exists():
raise Exception(f"Addon folder {addon_folder} contains meta.json")

addons_to_copy_into_anki_addons_folders.append((addon_name, addon_folder))


Expand Down

0 comments on commit 4123853

Please sign in to comment.