2024-11-11 21:38:13 +01:00
|
|
|
from http import HTTPStatus
|
|
|
|
from pathlib import Path
|
|
|
|
|
2024-12-31 15:58:10 +01:00
|
|
|
import pytest
|
2024-10-08 14:29:45 +02:00
|
|
|
import requests
|
|
|
|
|
2024-11-11 21:38:13 +01:00
|
|
|
from akkudoktoreos.config import CONFIG_FILE_NAME, load_config
|
|
|
|
|
2024-10-09 19:21:42 +02:00
|
|
|
|
2024-11-11 21:38:13 +01:00
|
|
|
def test_fixture_setup(server, tmp_path: Path) -> None:
|
|
|
|
"""Test if the fixture sets up the server with the env var."""
|
|
|
|
# validate correct path in server
|
|
|
|
config = load_config(tmp_path, False)
|
|
|
|
assert tmp_path.joinpath(CONFIG_FILE_NAME).is_file()
|
|
|
|
cache = tmp_path / config.directories.cache
|
|
|
|
assert cache.is_dir()
|
2024-10-08 14:29:45 +02:00
|
|
|
|
2024-11-11 21:38:13 +01:00
|
|
|
|
|
|
|
def test_server(server, tmp_path: Path):
|
2024-11-10 23:27:52 +01:00
|
|
|
"""Test the server."""
|
2024-12-31 15:58:10 +01:00
|
|
|
pytest.skip() # temp skip test until 01.01.24
|
2024-10-08 14:29:45 +02:00
|
|
|
result = requests.get(f"{server}/gesamtlast_simple?year_energy=2000&")
|
2024-11-11 21:38:13 +01:00
|
|
|
assert result.status_code == HTTPStatus.OK
|
|
|
|
|
|
|
|
config = load_config(tmp_path, False)
|
|
|
|
assert len(result.json()) == config.eos.prediction_hours
|