mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-09-13 07:21:16 +00:00
Reasonable defaults, isolate tests, EOS_LOGGING_LEVEL, EOS_CONFIG_DIR
* 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).
This commit is contained in:
committed by
GitHub
parent
267a9bf427
commit
75987db9e1
@@ -4,7 +4,6 @@ from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from akkudoktoreos.config.config import get_config
|
||||
from akkudoktoreos.core.ems import get_ems
|
||||
from akkudoktoreos.prediction.prediction import get_prediction
|
||||
from akkudoktoreos.prediction.pvforecastakkudoktor import (
|
||||
@@ -22,12 +21,8 @@ FILE_TESTDATA_PV_FORECAST_INPUT_1 = DIR_TESTDATA.joinpath("pv_forecast_input_1.j
|
||||
FILE_TESTDATA_PV_FORECAST_RESULT_1 = DIR_TESTDATA.joinpath("pv_forecast_result_1.txt")
|
||||
|
||||
|
||||
config_eos = get_config()
|
||||
ems_eos = get_ems()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_settings(reset_config):
|
||||
def sample_settings(config_eos):
|
||||
"""Fixture that adds settings data to the global config."""
|
||||
settings = {
|
||||
"prediction_hours": 48,
|
||||
@@ -223,6 +218,7 @@ def test_pvforecast_akkudoktor_update_with_sample_forecast(
|
||||
mock_get.return_value = mock_response
|
||||
|
||||
# Test that update properly inserts data records
|
||||
ems_eos = get_ems()
|
||||
ems_eos.set_start_datetime(sample_forecast_start)
|
||||
provider.update_data(force_enable=True, force_update=True)
|
||||
assert compare_datetimes(provider.start_datetime, sample_forecast_start).equal
|
||||
@@ -230,10 +226,9 @@ def test_pvforecast_akkudoktor_update_with_sample_forecast(
|
||||
|
||||
|
||||
# Report Generation Test
|
||||
def test_report_ac_power_and_measurement(provider):
|
||||
def test_report_ac_power_and_measurement(provider, config_eos):
|
||||
# Set the configuration
|
||||
config = get_config()
|
||||
config.merge_settings_from_dict(sample_config_data)
|
||||
config_eos.merge_settings_from_dict(sample_config_data)
|
||||
|
||||
record = PVForecastAkkudoktorDataRecord(
|
||||
pvforecastakkudoktor_ac_power_measured=900.0,
|
||||
@@ -275,6 +270,7 @@ def test_timezone_behaviour(
|
||||
|
||||
provider.clear()
|
||||
assert len(provider) == 0
|
||||
ems_eos = get_ems()
|
||||
ems_eos.set_start_datetime(other_start_datetime)
|
||||
provider.update_data(force_update=True)
|
||||
assert compare_datetimes(provider.start_datetime, other_start_datetime).equal
|
||||
|
Reference in New Issue
Block a user