mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
* Tests for class_load_container v2 - file as same name as class - useless numpy conversations removed - switched to built-in type tests - human readable tests included * ruff * removed dupicate empty list * load_aggregator: collections.abc.Sequence --------- Co-authored-by: Dominique Lasserre <lasserre.d@gmail.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import pytest
|
|
|
|
from akkudoktoreos.prediction.load_aggregator import LoadAggregator
|
|
|
|
|
|
def test_initialization():
|
|
aggregator = LoadAggregator()
|
|
assert aggregator.prediction_hours == 24
|
|
assert aggregator.loads == {}
|
|
|
|
|
|
def test_add_load_valid():
|
|
aggregator = LoadAggregator(prediction_hours=3)
|
|
aggregator.add_load("Source1", [10.0, 20.0, 30.0])
|
|
assert aggregator.loads["Source1"] == [10.0, 20.0, 30.0]
|
|
|
|
|
|
def test_add_load_invalid_length():
|
|
aggregator = LoadAggregator(prediction_hours=3)
|
|
with pytest.raises(ValueError, match="Total load inconsistent lengths in arrays: Source1 2"):
|
|
aggregator.add_load("Source1", [10.0, 20.0])
|
|
|
|
|
|
def test_calculate_total_load_empty():
|
|
aggregator = LoadAggregator()
|
|
assert aggregator.calculate_total_load() == []
|
|
|
|
|
|
def test_calculate_total_load():
|
|
aggregator = LoadAggregator(prediction_hours=3)
|
|
aggregator.add_load("Source1", [10.0, 20.0, 30.0])
|
|
aggregator.add_load("Source2", [5.0, 15.0, 25.0])
|
|
assert aggregator.calculate_total_load() == [15.0, 35.0, 55.0]
|
|
|
|
|
|
def test_calculate_total_load_single_source():
|
|
aggregator = LoadAggregator(prediction_hours=3)
|
|
aggregator.add_load("Source1", [10.0, 20.0, 30.0])
|
|
assert aggregator.calculate_total_load() == [10.0, 20.0, 30.0]
|