Json configuration (#141)

* Add json config
* Adjust code to new config

---------

Co-authored-by: Chris <git@nootch.de>
This commit is contained in:
Chris
2024-11-11 21:38:13 +01:00
committed by GitHub
parent fc74cde56f
commit ed3226e522
21 changed files with 726 additions and 171 deletions

View File

@@ -3,10 +3,21 @@ import os
import subprocess
import sys
import time
from pathlib import Path
import pytest
from xprocess import ProcessStarter
from akkudoktoreos.config import EOS_DIR, AppConfig, load_config
@pytest.fixture(name="tmp_config")
def load_config_tmp(tmp_path: Path) -> AppConfig:
"""Creates an AppConfig from default.config.json with a tmp output directory."""
config = load_config(tmp_path)
config.directories.output = tmp_path
return config
@pytest.fixture(autouse=True)
def disable_debug_logging():
@@ -29,7 +40,7 @@ def is_full_run(request):
@pytest.fixture
def server(xprocess):
def server(xprocess, tmp_path: Path):
"""Fixture to start the server.
Provides URL of the server.
@@ -45,8 +56,7 @@ def server(xprocess):
stderr=subprocess.PIPE,
)
except subprocess.CalledProcessError:
test_dir = os.path.dirname(os.path.realpath(__file__))
project_dir = os.path.abspath(os.path.join(test_dir, ".."))
project_dir = Path(__file__).parent.parent
subprocess.run(
[sys.executable, "-m", "pip", "install", "-e", project_dir],
check=True,
@@ -56,14 +66,15 @@ def server(xprocess):
# command to start server process
args = [sys.executable, "-m", "akkudoktoreosserver.flask_server"]
env = {EOS_DIR: f"{tmp_path}", **os.environ.copy()}
# startup pattern
pattern = "Debugger PIN:"
# search the first 12 lines for the startup pattern, if not found
# search the first 30 lines for the startup pattern, if not found
# a RuntimeError will be raised informing the user
max_read_lines = 12
max_read_lines = 30
# will wait for 10 seconds before timing out
# will wait for 30 seconds before timing out
timeout = 30
# xprocess will now attempt to clean up upon interruptions