various #16
1 changed files with 37 additions and 0 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from collections import UserList
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from pytest_abra.coordinator import Coordinator
|
from pytest_abra.coordinator import Coordinator
|
||||||
from pytest_abra.dir_manager import DirManager
|
from pytest_abra.dir_manager import DirManager
|
||||||
|
|
||||||
|
|
@ -23,3 +28,35 @@ def test_load_test_credentials(tmp_path: Path):
|
||||||
|
|
||||||
Coordinator.load_test_credentials(DIR)
|
Coordinator.load_test_credentials(DIR)
|
||||||
assert test_user_before == os.environ["TEST_USER"]
|
assert test_user_before == os.environ["TEST_USER"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def tmp_recipes(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
||||||
|
tmp_recipes_target = tmp_path_factory.mktemp("recipes")
|
||||||
|
recipes_dir_source = Path("recipes")
|
||||||
|
shutil.copytree(recipes_dir_source, tmp_recipes_target, dirs_exist_ok=True)
|
||||||
|
return tmp_recipes_target
|
||||||
|
|
||||||
|
|
||||||
|
def test_runner_runner_dict_import(tmp_recipes: Path):
|
||||||
|
"""import from recipes dict should work, because create_runner_dict has sys.path.append"""
|
||||||
|
|
||||||
|
RUNNER_DICT = Coordinator.create_runner_dict(tmp_recipes)
|
||||||
|
assert len(RUNNER_DICT.keys()) > 0
|
||||||
|
|
||||||
|
|
||||||
|
# def test_runner_runner_dict_import_patched(tmp_recipes: Path, monkeypatch):
|
||||||
|
# """import from recipes dict should fail without sys.path.append"""
|
||||||
|
|
||||||
|
# class MockPath(UserList):
|
||||||
|
# def append(self, item):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
# monkeypatch.setattr(sys, "path", MockPath())
|
||||||
|
|
||||||
|
# with pytest.raises(ModuleNotFoundError):
|
||||||
|
# Coordinator.create_runner_dict(tmp_recipes)
|
||||||
|
|
||||||
|
|
||||||
|
# def test_something():
|
||||||
|
# import authentik
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue