2025-10-28 02:50:31 +01:00
|
|
|
import json
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-02-22 14:12:42 +01:00
|
|
|
from akkudoktoreos.core.coreabc import get_ems
|
2025-10-28 02:50:31 +01:00
|
|
|
from akkudoktoreos.prediction.feedintarifffixed import FeedInTariffFixed
|
|
|
|
|
from akkudoktoreos.utils.datetimeutil import compare_datetimes, to_datetime
|
|
|
|
|
|
|
|
|
|
DIR_TESTDATA = Path(__file__).absolute().parent.joinpath("testdata")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def provider(config_eos):
|
|
|
|
|
"""Fixture to create a ElecPriceProvider instance."""
|
|
|
|
|
settings = {
|
|
|
|
|
"feedintariff": {
|
|
|
|
|
"provider": "FeedInTariffFixed",
|
2026-07-20 14:37:03 +02:00
|
|
|
"feedintarifffixed": {
|
|
|
|
|
"feed_in_tariff_kwh": 0.078,
|
2025-10-28 02:50:31 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
config_eos.merge_settings_from_dict(settings)
|
|
|
|
|
assert config_eos.feedintariff.provider == "FeedInTariffFixed"
|
|
|
|
|
provider = FeedInTariffFixed()
|
|
|
|
|
assert provider.enabled()
|
|
|
|
|
return provider
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------
|
|
|
|
|
# General forecast
|
|
|
|
|
# ------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_singleton_instance(provider):
|
|
|
|
|
"""Test that ElecPriceForecast behaves as a singleton."""
|
|
|
|
|
another_instance = FeedInTariffFixed()
|
|
|
|
|
assert provider is another_instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_provider(provider, config_eos):
|
|
|
|
|
"""Test requesting an unsupported provider."""
|
|
|
|
|
settings = {
|
|
|
|
|
"feedintariff": {
|
|
|
|
|
"provider": "<invalid>",
|
2026-07-20 14:37:03 +02:00
|
|
|
"feedintarifffixed": {
|
|
|
|
|
"feed_in_tariff_kwh": 0.078,
|
2025-10-28 02:50:31 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
with pytest.raises(ValueError, match="not a valid feed in tariff provider"):
|
|
|
|
|
config_eos.merge_settings_from_dict(settings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------
|
|
|
|
|
# Fixed feed in tariv values
|
|
|
|
|
# ------------------------------------------------
|