cleanup (#18)
- remove demo runner - improve docs - rename all tests to test_* (previously, also setup_* and cleanup_* existed) to improve stability as it is not guaranteed that pytest.ini is loaded. - improve logging formatting - improve full integration test Reviewed-on: local-it-infrastructure/e2e_tests#18 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
8b9dd47f9e
commit
0fafa22272
18 changed files with 58 additions and 81 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -8,13 +9,25 @@ from pytest_abra.utils import load_json_to_environ
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def session_tmp_path_testout(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
||||
return tmp_path_factory.mktemp("test_out")
|
||||
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
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def tmp_output(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
||||
return tmp_path_factory.mktemp("output")
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_abratest_cli_full_integration(session_tmp_path_testout: Path):
|
||||
"""run abratest against the dev instance"""
|
||||
def test_abratest_cli_full_integration(tmp_output: Path, tmp_recipes: Path):
|
||||
"""Full integration test of abratest against the dev instance. Recipes dir not in path
|
||||
|
||||
this test is hard to debug as the output dir is in tmp. If required, try
|
||||
pytest -s
|
||||
or find the tmp dir to look into test outputs"""
|
||||
|
||||
# --------------------- load credentials to env variables -------------------- #
|
||||
|
||||
|
|
@ -33,9 +46,9 @@ def test_abratest_cli_full_integration(session_tmp_path_testout: Path):
|
|||
|
||||
# ----------------------------------- dirs ----------------------------------- #
|
||||
|
||||
RECIPES_DIR = Path("./recipes").resolve()
|
||||
# OUTPUT_DIR = Path("./test-output").resolve()
|
||||
OUTPUT_DIR = session_tmp_path_testout.resolve()
|
||||
RECIPES_DIR = tmp_recipes.resolve()
|
||||
# RECIPES_DIR = Path("recipes")
|
||||
OUTPUT_DIR = tmp_output.resolve()
|
||||
|
||||
# ------------------------------------ run ----------------------------------- #
|
||||
|
||||
|
|
@ -57,8 +70,8 @@ def test_abratest_cli_full_integration(session_tmp_path_testout: Path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_results_abra(session_tmp_path_testout: Path):
|
||||
OUTPUT_DIR = session_tmp_path_testout.resolve()
|
||||
def test_full_integration_results(tmp_output: Path):
|
||||
OUTPUT_DIR = tmp_output.resolve()
|
||||
|
||||
DIR = DirManager(output_dir=OUTPUT_DIR, session_id="abc")
|
||||
all_files = [f.name for f in DIR.STATUS.rglob("*")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
|
@ -36,7 +37,16 @@ def tmp_recipes(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
|||
return tmp_recipes_target
|
||||
|
||||
|
||||
def test_runner_runner_dict_import(tmp_recipes: Path):
|
||||
@pytest.fixture
|
||||
def clear_sys_path():
|
||||
"""clear sys.path before test, restore after"""
|
||||
syspath_copy = sys.path.copy()
|
||||
sys.path.clear()
|
||||
yield
|
||||
sys.path.extend(syspath_copy)
|
||||
|
||||
|
||||
def test_runner_runner_dict_import(tmp_recipes: Path, clear_sys_path):
|
||||
"""import from recipes dict should work, because create_runner_dict has sys.path.append"""
|
||||
|
||||
RUNNER_DICT = Coordinator.create_runner_dict(tmp_recipes)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,26 @@
|
|||
|
||||
import time
|
||||
import pytest
|
||||
from pytest_abra.dir_manager import DirManager
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from pytest_abra.dir_manager import DirManager
|
||||
|
||||
|
||||
def test_get_latest_session_id_from_non_existing_dir(tmp_path: Path):
|
||||
out = DirManager.get_latest_session_id(tmp_path / "not_exist")
|
||||
assert out is None
|
||||
|
||||
|
||||
def test_get_latest_session_id_from_empty_dir(tmp_path: Path):
|
||||
out = DirManager.get_latest_session_id(tmp_path)
|
||||
assert out is None
|
||||
|
||||
|
||||
def test_get_latest_session_id_single(tmp_path: Path):
|
||||
(tmp_path / "a").mkdir()
|
||||
out = DirManager.get_latest_session_id(tmp_path)
|
||||
assert out == "a"
|
||||
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_get_latest_session_id(tmp_path: Path):
|
||||
|
|
@ -26,5 +29,3 @@ def test_get_latest_session_id(tmp_path: Path):
|
|||
(tmp_path / "b").mkdir()
|
||||
out = DirManager.get_latest_session_id(tmp_path)
|
||||
assert out == "b"
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue