mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-24 18:58:12 +00:00
fix: data management conversion to async (#1185)
Fix test warnings left over from data management conversion to async design. Mostly tagging async tests. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -52,7 +52,6 @@ def cache_store():
|
||||
return CacheFileStore()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
class TestElecPriceEnergyCharts:
|
||||
# ------------------------------------------------
|
||||
# General forecast
|
||||
@@ -63,19 +62,16 @@ class TestElecPriceEnergyCharts:
|
||||
another_instance = ElecPriceEnergyCharts()
|
||||
assert provider is another_instance
|
||||
|
||||
|
||||
def test_invalid_provider(self, provider, monkeypatch):
|
||||
"""Test requesting an unsupported provider."""
|
||||
monkeypatch.setenv("EOS_ELECPRICE__ELECPRICE_PROVIDER", "<invalid>")
|
||||
provider.config.reset_settings()
|
||||
assert not provider.enabled()
|
||||
|
||||
|
||||
# ------------------------------------------------
|
||||
# Akkudoktor
|
||||
# ------------------------------------------------
|
||||
|
||||
|
||||
@patch("akkudoktoreos.prediction.elecpriceenergycharts.logger.error")
|
||||
def test_validate_data_invalid_format(self, mock_logger, provider):
|
||||
"""Test validation for invalid Energy-Charts data."""
|
||||
@@ -84,7 +80,6 @@ class TestElecPriceEnergyCharts:
|
||||
provider._validate_data(invalid_data)
|
||||
mock_logger.assert_called_once_with(mock_logger.call_args[0][0])
|
||||
|
||||
|
||||
@patch("requests.get")
|
||||
def test_request_forecast(self, mock_get, provider, sample_energycharts_json):
|
||||
"""Test requesting forecast from Energy-Charts."""
|
||||
@@ -101,7 +96,7 @@ class TestElecPriceEnergyCharts:
|
||||
assert energy_charts_data.unix_seconds[0] == 1733785200
|
||||
assert energy_charts_data.price[0] == 92.85
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("requests.get")
|
||||
async def test_update_data(self, mock_get, provider, sample_energycharts_json, cache_store):
|
||||
"""Test fetching forecast from Energy-Charts."""
|
||||
@@ -133,7 +128,7 @@ class TestElecPriceEnergyCharts:
|
||||
)
|
||||
assert len(np_price_array) == provider.total_hours
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("requests.get")
|
||||
async def test_update_data_with_incomplete_forecast(self, mock_get, provider):
|
||||
"""Test `_update_data` with incomplete or missing forecast data."""
|
||||
@@ -146,7 +141,6 @@ class TestElecPriceEnergyCharts:
|
||||
with pytest.raises(ValueError):
|
||||
await provider._update_data(force_update=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_code, exception",
|
||||
[(400, requests.exceptions.HTTPError), (500, requests.exceptions.HTTPError), (200, None)],
|
||||
@@ -169,7 +163,7 @@ class TestElecPriceEnergyCharts:
|
||||
else:
|
||||
provider._request_forecast()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("requests.get")
|
||||
@patch("akkudoktoreos.core.cache.CacheFileStore")
|
||||
async def test_cache_integration(self, mock_cache, mock_get, provider, sample_energycharts_json):
|
||||
@@ -188,7 +182,7 @@ class TestElecPriceEnergyCharts:
|
||||
mock_cache_instance.create.assert_called_once()
|
||||
mock_cache_instance.get.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_key_to_array_resampling(self, provider):
|
||||
"""Test resampling of forecast data to NumPy array."""
|
||||
await provider.update_data(force_update=True)
|
||||
@@ -201,7 +195,6 @@ class TestElecPriceEnergyCharts:
|
||||
assert isinstance(array, np.ndarray)
|
||||
assert len(array) == provider.total_hours
|
||||
|
||||
|
||||
@patch("requests.get")
|
||||
def test_request_forecast_url_bidding_zone_is_value(self, mock_get, provider, sample_energycharts_json):
|
||||
"""Test that the bidding zone in the API URL uses the enum *value* (e.g. 'DE-LU'),
|
||||
@@ -238,12 +231,10 @@ class TestElecPriceEnergyCharts:
|
||||
f"but got bzn='{bzn_value}' in URL: {actual_url}"
|
||||
)
|
||||
|
||||
|
||||
# ------------------------------------------------
|
||||
# Development Energy Charts
|
||||
# ------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="For development only")
|
||||
def test_energycharts_development_forecast_data(self, provider):
|
||||
"""Fetch data from real Energy-Charts server."""
|
||||
|
||||
Reference in New Issue
Block a user