mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 00:45:22 +00:00
* Add EOS_CONFIG_DIR to set config dir (relative path to EOS_DIR or absolute path). - config_folder_path read-only - config_file_path read-only * Default values to support app start with empty config: - latitude/longitude (Berlin) - optimization_ev_available_charge_rates_percent (null, so model default value is used) - Enable Akkudoktor electricity price forecast (docker-compose). * Fix some endpoints (empty data, remove unused params, fix types). * cacheutil: Use cache dir. Closes #240 * Support EOS_LOGGING_LEVEL environment variable to set log level. * tests: All tests use separate temporary config - Add pytest switch --check-config-side-effect to check user config file existence after each test. Will also fail if user config existed before test execution (but will only check after the test has run). Enable flag in github workflow. - Globally mock platformdirs in config module. Now no longer required to patch individually. Function calls to config instance (e.g. merge_settings_from_dict) were unaffected previously. * Set Berlin as default location (default config/docker-compose).
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
import json
|
||
from pathlib import Path
|
||
from unittest.mock import patch
|
||
|
||
DIR_PROJECT_ROOT = Path(__file__).parent.parent
|
||
DIR_TESTDATA = Path(__file__).parent / "testdata"
|
||
|
||
|
||
def test_openapi_spec_current(config_eos):
|
||
"""Verify the openapi spec hasn´t changed."""
|
||
old_spec_path = DIR_PROJECT_ROOT / "docs" / "akkudoktoreos" / "openapi.json"
|
||
new_spec_path = DIR_TESTDATA / "openapi-new.json"
|
||
# Patch get_config and import within guard to patch global variables within the fastapi_server module.
|
||
with patch("akkudoktoreos.config.config.get_config", return_value=config_eos):
|
||
from generate_openapi import generate_openapi
|
||
|
||
generate_openapi(new_spec_path)
|
||
with open(new_spec_path) as f_new:
|
||
new_spec = json.load(f_new)
|
||
with open(old_spec_path) as f_old:
|
||
old_spec = json.load(f_old)
|
||
|
||
# Serialize to ensure comparison is consistent
|
||
new_spec = json.dumps(new_spec, indent=4, sort_keys=True)
|
||
old_spec = json.dumps(old_spec, indent=4, sort_keys=True)
|
||
|
||
assert new_spec == old_spec
|