20 lines
760 B
Python
20 lines
760 B
Python
import polars as pl
|
|
import requests_mock
|
|
from collectors.smard import fetch_smard_data
|
|
|
|
def test_fetch_smard_data():
|
|
with requests_mock.Mocker() as m:
|
|
# Mock index call
|
|
m.get("https://www.smard.de/app/chart_data/4169/DE-LU/index_hour.json",
|
|
json={"timestamps": [1700000000000]})
|
|
# Mock data call
|
|
m.get("https://www.smard.de/app/chart_data/4169/DE-LU/4169_DE-LU_hour_1700000000000.json",
|
|
json={
|
|
"series": [[1700000000000, 50.0], [1700003600000, 60.0]]
|
|
})
|
|
|
|
df = fetch_smard_data(filter_id=4169)
|
|
assert isinstance(df, pl.DataFrame)
|
|
assert df.shape == (2, 2)
|
|
assert "value" in df.columns
|
|
assert df["value"][0] == 50.0
|