mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
pre-commit update and python 3.11 req
This commit is contained in:
parent
1f30d4e403
commit
b20083a3dd
@ -12,12 +12,12 @@ repos:
|
|||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
exclude: '\.rst$' # Exclude .rst files
|
exclude: '\.rst$' # Exclude .rst files
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.13.2
|
rev: 6.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
name: isort
|
name: isort
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.6.8
|
rev: v0.9.9
|
||||||
hooks:
|
hooks:
|
||||||
# Run the linter and fix simple issues automatically
|
# Run the linter and fix simple issues automatically
|
||||||
- id: ruff
|
- id: ruff
|
||||||
@ -25,7 +25,7 @@ repos:
|
|||||||
# Run the formatter.
|
# Run the formatter.
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: 'v1.13.0'
|
rev: 'v1.15.0'
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
@ -34,7 +34,7 @@ repos:
|
|||||||
- "numpy==2.1.3"
|
- "numpy==2.1.3"
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
- repo: https://github.com/jackdewinter/pymarkdown
|
- repo: https://github.com/jackdewinter/pymarkdown
|
||||||
rev: main
|
rev: v0.9.28
|
||||||
hooks:
|
hooks:
|
||||||
- id: pymarkdown
|
- id: pymarkdown
|
||||||
files: ^docs/
|
files: ^docs/
|
||||||
|
@ -10,7 +10,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|||||||
|
|
||||||
## System requirements
|
## System requirements
|
||||||
|
|
||||||
- Python >= 3.10, < 3.13
|
- Python >= 3.11, < 3.13
|
||||||
- Architecture: amd64, aarch64 (armv8)
|
- Architecture: amd64, aarch64 (armv8)
|
||||||
- OS: Linux, Windows, macOS
|
- OS: Linux, Windows, macOS
|
||||||
|
|
||||||
|
@ -287,11 +287,11 @@
|
|||||||
|
|
||||||
| Name | Type | Read-Only | Default | Description |
|
| Name | Type | Read-Only | Default | Description |
|
||||||
| ---- | ---- | --------- | ------- | ----------- |
|
| ---- | ---- | --------- | ------- | ----------- |
|
||||||
| `server_eos_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | EOS server IP address. |
|
| `server_eos_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `127.0.0.1` | EOS server IP address. |
|
||||||
| `server_eos_port` | `Optional[int]` | `rw` | `8503` | EOS server IP port number. |
|
| `server_eos_port` | `Optional[int]` | `rw` | `8503` | EOS server IP port number. |
|
||||||
| `server_eos_startup_eosdash` | `Optional[bool]` | `rw` | `True` | EOS server to start EOSdash server. |
|
| `server_eos_startup_eosdash` | `Optional[bool]` | `rw` | `True` | EOS server to start EOSdash server. |
|
||||||
| `server_eos_verbose` | `Optional[bool]` | `rw` | `False` | Enable debug output |
|
| `server_eos_verbose` | `Optional[bool]` | `rw` | `False` | Enable debug output |
|
||||||
| `server_eosdash_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `0.0.0.0` | EOSdash server IP address. |
|
| `server_eosdash_host` | `Optional[pydantic.networks.IPvAnyAddress]` | `rw` | `127.0.0.1` | EOSdash server IP address. |
|
||||||
| `server_eosdash_port` | `Optional[int]` | `rw` | `8504` | EOSdash server IP port number. |
|
| `server_eosdash_port` | `Optional[int]` | `rw` | `8504` | EOSdash server IP port number. |
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
17910
openapi.json
17910
openapi.json
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ authors = [
|
|||||||
description = "This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period."
|
description = "This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {file = "LICENSE"}
|
license = {file = "LICENSE"}
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.11"
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
|
@ -1224,14 +1224,14 @@ class DataImportMixin:
|
|||||||
# We jump back by 1 hour
|
# We jump back by 1 hour
|
||||||
# Repeat the value(s) (reuse value index)
|
# Repeat the value(s) (reuse value index)
|
||||||
for i in range(interval_steps_per_hour):
|
for i in range(interval_steps_per_hour):
|
||||||
logger.debug(f"{i+1}: Repeat at {next_time} with index {value_index}")
|
logger.debug(f"{i + 1}: Repeat at {next_time} with index {value_index}")
|
||||||
timestamps_with_indices.append((next_time, value_index))
|
timestamps_with_indices.append((next_time, value_index))
|
||||||
next_time = next_time.add(seconds=interval.total_seconds())
|
next_time = next_time.add(seconds=interval.total_seconds())
|
||||||
else:
|
else:
|
||||||
# We jump forward by 1 hour
|
# We jump forward by 1 hour
|
||||||
# Drop the value(s)
|
# Drop the value(s)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{i+1}: Skip {interval_steps_per_hour} at {next_time} with index {value_index}"
|
f"{i + 1}: Skip {interval_steps_per_hour} at {next_time} with index {value_index}"
|
||||||
)
|
)
|
||||||
value_index += interval_steps_per_hour
|
value_index += interval_steps_per_hour
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ def test_soc_limits(setup_pv_battery):
|
|||||||
def test_max_charge_power_w(setup_pv_battery):
|
def test_max_charge_power_w(setup_pv_battery):
|
||||||
battery = setup_pv_battery
|
battery = setup_pv_battery
|
||||||
battery.setup()
|
battery.setup()
|
||||||
assert (
|
assert battery.parameters.max_charge_power_w == 8000, (
|
||||||
battery.parameters.max_charge_power_w == 8000
|
"Default max charge power should be 5000W, We ask for 8000W here"
|
||||||
), "Default max charge power should be 5000W, We ask for 8000W here"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_charge_energy_within_limits(setup_pv_battery):
|
def test_charge_energy_within_limits(setup_pv_battery):
|
||||||
@ -140,9 +140,9 @@ def test_charge_energy_exceeds_capacity(setup_pv_battery):
|
|||||||
# Try to overcharge beyond max capacity
|
# Try to overcharge beyond max capacity
|
||||||
charged_wh, losses_wh = battery.charge_energy(wh=20000, hour=2)
|
charged_wh, losses_wh = battery.charge_energy(wh=20000, hour=2)
|
||||||
|
|
||||||
assert (
|
assert charged_wh + initial_soc_wh <= battery.max_soc_wh, (
|
||||||
charged_wh + initial_soc_wh <= battery.max_soc_wh
|
"Charging should not exceed max capacity"
|
||||||
), "Charging should not exceed max capacity"
|
)
|
||||||
assert losses_wh >= 0, "Losses should not be negative"
|
assert losses_wh >= 0, "Losses should not be negative"
|
||||||
assert battery.soc_wh == battery.max_soc_wh, "SOC should be at max after overcharge attempt"
|
assert battery.soc_wh == battery.max_soc_wh, "SOC should be at max after overcharge attempt"
|
||||||
|
|
||||||
@ -172,9 +172,9 @@ def test_charge_energy_relative_power(setup_pv_battery):
|
|||||||
|
|
||||||
assert charged_wh > 0, "Charging should occur with relative power"
|
assert charged_wh > 0, "Charging should occur with relative power"
|
||||||
assert losses_wh >= 0, "Losses should not be negative"
|
assert losses_wh >= 0, "Losses should not be negative"
|
||||||
assert (
|
assert charged_wh <= battery.max_charge_power_w * relative_power, (
|
||||||
charged_wh <= battery.max_charge_power_w * relative_power
|
"Charging should respect relative power limit"
|
||||||
), "Charging should respect relative power limit"
|
)
|
||||||
assert battery.soc_wh > 0, "SOC should increase after charging"
|
assert battery.soc_wh > 0, "SOC should increase after charging"
|
||||||
|
|
||||||
|
|
||||||
@ -201,19 +201,19 @@ def test_car_and_pv_battery_discharge_and_max_charge_power(setup_pv_battery, set
|
|||||||
# Test discharge for PV battery
|
# Test discharge for PV battery
|
||||||
pv_discharged_wh, pv_loss_wh = pv_battery.discharge_energy(3000, 5)
|
pv_discharged_wh, pv_loss_wh = pv_battery.discharge_energy(3000, 5)
|
||||||
assert pv_discharged_wh > 0, "PV battery should discharge energy"
|
assert pv_discharged_wh > 0, "PV battery should discharge energy"
|
||||||
assert (
|
assert pv_battery.current_soc_percentage() >= pv_battery.parameters.min_soc_percentage, (
|
||||||
pv_battery.current_soc_percentage() >= pv_battery.parameters.min_soc_percentage
|
"PV battery SOC should stay above min SOC"
|
||||||
), "PV battery SOC should stay above min SOC"
|
)
|
||||||
assert (
|
assert pv_battery.parameters.max_charge_power_w == 8000, (
|
||||||
pv_battery.parameters.max_charge_power_w == 8000
|
"PV battery max charge power should remain as defined"
|
||||||
), "PV battery max charge power should remain as defined"
|
)
|
||||||
|
|
||||||
# Test discharge for car battery
|
# Test discharge for car battery
|
||||||
car_discharged_wh, car_loss_wh = car_battery.discharge_energy(5000, 10)
|
car_discharged_wh, car_loss_wh = car_battery.discharge_energy(5000, 10)
|
||||||
assert car_discharged_wh > 0, "Car battery should discharge energy"
|
assert car_discharged_wh > 0, "Car battery should discharge energy"
|
||||||
assert (
|
assert car_battery.current_soc_percentage() >= car_battery.parameters.min_soc_percentage, (
|
||||||
car_battery.current_soc_percentage() >= car_battery.parameters.min_soc_percentage
|
"Car battery SOC should stay above min SOC"
|
||||||
), "Car battery SOC should stay above min SOC"
|
)
|
||||||
assert (
|
assert car_battery.parameters.max_charge_power_w == 7000, (
|
||||||
car_battery.parameters.max_charge_power_w == 7000
|
"Car battery max charge power should remain as defined"
|
||||||
), "Car battery max charge power should remain as defined"
|
)
|
||||||
|
@ -283,69 +283,69 @@ def test_simulation(create_ems_instance):
|
|||||||
assert SimulationResult(**result) is not None
|
assert SimulationResult(**result) is not None
|
||||||
|
|
||||||
# Check the length of the main arrays
|
# Check the length of the main arrays
|
||||||
assert (
|
assert len(result["Last_Wh_pro_Stunde"]) == 47, (
|
||||||
len(result["Last_Wh_pro_Stunde"]) == 47
|
"The length of 'Last_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Last_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 47, (
|
||||||
len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 47
|
"The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Netzbezug_Wh_pro_Stunde"]) == 47, (
|
||||||
len(result["Netzbezug_Wh_pro_Stunde"]) == 47
|
"The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Kosten_Euro_pro_Stunde"]) == 47, (
|
||||||
len(result["Kosten_Euro_pro_Stunde"]) == 47
|
"The length of 'Kosten_Euro_pro_Stunde' should be 48."
|
||||||
), "The length of 'Kosten_Euro_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["akku_soc_pro_stunde"]) == 47, (
|
||||||
len(result["akku_soc_pro_stunde"]) == 47
|
"The length of 'akku_soc_pro_stunde' should be 48."
|
||||||
), "The length of 'akku_soc_pro_stunde' should be 48."
|
)
|
||||||
|
|
||||||
# Verify specific values in the 'Last_Wh_pro_Stunde' array
|
# Verify specific values in the 'Last_Wh_pro_Stunde' array
|
||||||
assert (
|
assert result["Last_Wh_pro_Stunde"][1] == 1527.13, (
|
||||||
result["Last_Wh_pro_Stunde"][1] == 1527.13
|
"The value at index 1 of 'Last_Wh_pro_Stunde' should be 1527.13."
|
||||||
), "The value at index 1 of 'Last_Wh_pro_Stunde' should be 1527.13."
|
)
|
||||||
assert (
|
assert result["Last_Wh_pro_Stunde"][2] == 1468.88, (
|
||||||
result["Last_Wh_pro_Stunde"][2] == 1468.88
|
"The value at index 2 of 'Last_Wh_pro_Stunde' should be 1468.88."
|
||||||
), "The value at index 2 of 'Last_Wh_pro_Stunde' should be 1468.88."
|
)
|
||||||
assert (
|
assert result["Last_Wh_pro_Stunde"][12] == 1132.03, (
|
||||||
result["Last_Wh_pro_Stunde"][12] == 1132.03
|
"The value at index 12 of 'Last_Wh_pro_Stunde' should be 1132.03."
|
||||||
), "The value at index 12 of 'Last_Wh_pro_Stunde' should be 1132.03."
|
)
|
||||||
|
|
||||||
# Verify that the value at index 0 is 'None'
|
# Verify that the value at index 0 is 'None'
|
||||||
# Check that 'Netzeinspeisung_Wh_pro_Stunde' and 'Netzbezug_Wh_pro_Stunde' are consistent
|
# Check that 'Netzeinspeisung_Wh_pro_Stunde' and 'Netzbezug_Wh_pro_Stunde' are consistent
|
||||||
assert (
|
assert result["Netzbezug_Wh_pro_Stunde"][1] == 0, (
|
||||||
result["Netzbezug_Wh_pro_Stunde"][1] == 0
|
"The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be 0."
|
||||||
), "The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be 0."
|
)
|
||||||
|
|
||||||
# Verify the total balance
|
# Verify the total balance
|
||||||
assert (
|
assert abs(result["Gesamtbilanz_Euro"] - 1.958185274567674) < 1e-5, (
|
||||||
abs(result["Gesamtbilanz_Euro"] - 1.958185274567674) < 1e-5
|
"Total balance should be 1.958185274567674."
|
||||||
), "Total balance should be 1.958185274567674."
|
)
|
||||||
|
|
||||||
# Check total revenue and total costs
|
# Check total revenue and total costs
|
||||||
assert (
|
assert abs(result["Gesamteinnahmen_Euro"] - 1.168863124510214) < 1e-5, (
|
||||||
abs(result["Gesamteinnahmen_Euro"] - 1.168863124510214) < 1e-5
|
"Total revenue should be 1.168863124510214."
|
||||||
), "Total revenue should be 1.168863124510214."
|
)
|
||||||
assert (
|
assert abs(result["Gesamtkosten_Euro"] - 3.127048399077888) < 1e-5, (
|
||||||
abs(result["Gesamtkosten_Euro"] - 3.127048399077888) < 1e-5
|
"Total costs should be 3.127048399077888 ."
|
||||||
), "Total costs should be 3.127048399077888 ."
|
)
|
||||||
|
|
||||||
# Check the losses
|
# Check the losses
|
||||||
assert (
|
assert abs(result["Gesamt_Verluste"] - 2871.5330639359036) < 1e-5, (
|
||||||
abs(result["Gesamt_Verluste"] - 2871.5330639359036) < 1e-5
|
"Total losses should be 2871.5330639359036 ."
|
||||||
), "Total losses should be 2871.5330639359036 ."
|
)
|
||||||
|
|
||||||
# Check the values in 'akku_soc_pro_stunde'
|
# Check the values in 'akku_soc_pro_stunde'
|
||||||
assert (
|
assert result["akku_soc_pro_stunde"][-1] == 42.151590909090906, (
|
||||||
result["akku_soc_pro_stunde"][-1] == 42.151590909090906
|
"The value at index -1 of 'akku_soc_pro_stunde' should be 42.151590909090906."
|
||||||
), "The value at index -1 of 'akku_soc_pro_stunde' should be 42.151590909090906."
|
)
|
||||||
assert (
|
assert result["akku_soc_pro_stunde"][1] == 60.08659090909091, (
|
||||||
result["akku_soc_pro_stunde"][1] == 60.08659090909091
|
"The value at index 1 of 'akku_soc_pro_stunde' should be 60.08659090909091."
|
||||||
), "The value at index 1 of 'akku_soc_pro_stunde' should be 60.08659090909091."
|
)
|
||||||
|
|
||||||
# Check home appliances
|
# Check home appliances
|
||||||
assert (
|
assert sum(ems.home_appliance.get_load_curve()) == 2000, (
|
||||||
sum(ems.home_appliance.get_load_curve()) == 2000
|
"The sum of 'ems.home_appliance.get_load_curve()' should be 2000."
|
||||||
), "The sum of 'ems.home_appliance.get_load_curve()' should be 2000."
|
)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
np.nansum(
|
np.nansum(
|
||||||
|
@ -216,44 +216,44 @@ def test_simulation(create_ems_instance):
|
|||||||
assert key in result, f"The key '{key}' should be present in the result."
|
assert key in result, f"The key '{key}' should be present in the result."
|
||||||
|
|
||||||
# Check the length of the main arrays
|
# Check the length of the main arrays
|
||||||
assert (
|
assert len(result["Last_Wh_pro_Stunde"]) == 48, (
|
||||||
len(result["Last_Wh_pro_Stunde"]) == 48
|
"The length of 'Last_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Last_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 48, (
|
||||||
len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 48
|
"The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Netzbezug_Wh_pro_Stunde"]) == 48, (
|
||||||
len(result["Netzbezug_Wh_pro_Stunde"]) == 48
|
"The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
|
||||||
), "The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["Kosten_Euro_pro_Stunde"]) == 48, (
|
||||||
len(result["Kosten_Euro_pro_Stunde"]) == 48
|
"The length of 'Kosten_Euro_pro_Stunde' should be 48."
|
||||||
), "The length of 'Kosten_Euro_pro_Stunde' should be 48."
|
)
|
||||||
assert (
|
assert len(result["akku_soc_pro_stunde"]) == 48, (
|
||||||
len(result["akku_soc_pro_stunde"]) == 48
|
"The length of 'akku_soc_pro_stunde' should be 48."
|
||||||
), "The length of 'akku_soc_pro_stunde' should be 48."
|
)
|
||||||
|
|
||||||
# Verfify DC and AC Charge Bins
|
# Verfify DC and AC Charge Bins
|
||||||
assert (
|
assert abs(result["akku_soc_pro_stunde"][2] - 44.70681818181818) < 1e-5, (
|
||||||
abs(result["akku_soc_pro_stunde"][2] - 44.70681818181818) < 1e-5
|
"'akku_soc_pro_stunde[2]' should be 44.70681818181818."
|
||||||
), "'akku_soc_pro_stunde[2]' should be 44.70681818181818."
|
)
|
||||||
assert (
|
assert abs(result["akku_soc_pro_stunde"][10] - 10.0) < 1e-5, (
|
||||||
abs(result["akku_soc_pro_stunde"][10] - 10.0) < 1e-5
|
"'akku_soc_pro_stunde[10]' should be 10."
|
||||||
), "'akku_soc_pro_stunde[10]' should be 10."
|
)
|
||||||
|
|
||||||
assert (
|
assert abs(result["Netzeinspeisung_Wh_pro_Stunde"][10] - 3946.93) < 1e-3, (
|
||||||
abs(result["Netzeinspeisung_Wh_pro_Stunde"][10] - 3946.93) < 1e-3
|
"'Netzeinspeisung_Wh_pro_Stunde[11]' should be 3946.93."
|
||||||
), "'Netzeinspeisung_Wh_pro_Stunde[11]' should be 3946.93."
|
)
|
||||||
|
|
||||||
assert (
|
assert abs(result["Netzeinspeisung_Wh_pro_Stunde"][11] - 0.0) < 1e-3, (
|
||||||
abs(result["Netzeinspeisung_Wh_pro_Stunde"][11] - 0.0) < 1e-3
|
"'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."
|
||||||
), "'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."
|
)
|
||||||
|
|
||||||
assert (
|
assert abs(result["akku_soc_pro_stunde"][20] - 10) < 1e-5, (
|
||||||
abs(result["akku_soc_pro_stunde"][20] - 10) < 1e-5
|
"'akku_soc_pro_stunde[20]' should be 10."
|
||||||
), "'akku_soc_pro_stunde[20]' should be 10."
|
)
|
||||||
assert (
|
assert abs(result["Last_Wh_pro_Stunde"][20] - 6050.98) < 1e-3, (
|
||||||
abs(result["Last_Wh_pro_Stunde"][20] - 6050.98) < 1e-3
|
"'Last_Wh_pro_Stunde[20]' should be 6050.98."
|
||||||
), "'Last_Wh_pro_Stunde[20]' should be 6050.98."
|
)
|
||||||
|
|
||||||
print("All tests passed successfully.")
|
print("All tests passed successfully.")
|
||||||
|
|
||||||
@ -266,9 +266,9 @@ def test_set_parameters(create_ems_instance):
|
|||||||
assert ems.load_energy_array is not None, "load_energy_array should not be None"
|
assert ems.load_energy_array is not None, "load_energy_array should not be None"
|
||||||
assert ems.pv_prediction_wh is not None, "pv_prediction_wh should not be None"
|
assert ems.pv_prediction_wh is not None, "pv_prediction_wh should not be None"
|
||||||
assert ems.elect_price_hourly is not None, "elect_price_hourly should not be None"
|
assert ems.elect_price_hourly is not None, "elect_price_hourly should not be None"
|
||||||
assert (
|
assert ems.elect_revenue_per_hour_arr is not None, (
|
||||||
ems.elect_revenue_per_hour_arr is not None
|
"elect_revenue_per_hour_arr should not be None"
|
||||||
), "elect_revenue_per_hour_arr should not be None"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_set_akku_discharge_hours(create_ems_instance):
|
def test_set_akku_discharge_hours(create_ems_instance):
|
||||||
@ -276,9 +276,9 @@ def test_set_akku_discharge_hours(create_ems_instance):
|
|||||||
ems = create_ems_instance
|
ems = create_ems_instance
|
||||||
discharge_hours = np.full(ems.config.prediction_hours, 1.0)
|
discharge_hours = np.full(ems.config.prediction_hours, 1.0)
|
||||||
ems.set_akku_discharge_hours(discharge_hours)
|
ems.set_akku_discharge_hours(discharge_hours)
|
||||||
assert np.array_equal(
|
assert np.array_equal(ems.battery.discharge_array, discharge_hours), (
|
||||||
ems.battery.discharge_array, discharge_hours
|
"Discharge hours should be set correctly"
|
||||||
), "Discharge hours should be set correctly"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_set_akku_ac_charge_hours(create_ems_instance):
|
def test_set_akku_ac_charge_hours(create_ems_instance):
|
||||||
@ -286,9 +286,9 @@ def test_set_akku_ac_charge_hours(create_ems_instance):
|
|||||||
ems = create_ems_instance
|
ems = create_ems_instance
|
||||||
ac_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
ac_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
||||||
ems.set_akku_ac_charge_hours(ac_charge_hours)
|
ems.set_akku_ac_charge_hours(ac_charge_hours)
|
||||||
assert np.array_equal(
|
assert np.array_equal(ems.ac_charge_hours, ac_charge_hours), (
|
||||||
ems.ac_charge_hours, ac_charge_hours
|
"AC charge hours should be set correctly"
|
||||||
), "AC charge hours should be set correctly"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_set_akku_dc_charge_hours(create_ems_instance):
|
def test_set_akku_dc_charge_hours(create_ems_instance):
|
||||||
@ -296,9 +296,9 @@ def test_set_akku_dc_charge_hours(create_ems_instance):
|
|||||||
ems = create_ems_instance
|
ems = create_ems_instance
|
||||||
dc_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
dc_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
||||||
ems.set_akku_dc_charge_hours(dc_charge_hours)
|
ems.set_akku_dc_charge_hours(dc_charge_hours)
|
||||||
assert np.array_equal(
|
assert np.array_equal(ems.dc_charge_hours, dc_charge_hours), (
|
||||||
ems.dc_charge_hours, dc_charge_hours
|
"DC charge hours should be set correctly"
|
||||||
), "DC charge hours should be set correctly"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_set_ev_charge_hours(create_ems_instance):
|
def test_set_ev_charge_hours(create_ems_instance):
|
||||||
@ -306,9 +306,9 @@ def test_set_ev_charge_hours(create_ems_instance):
|
|||||||
ems = create_ems_instance
|
ems = create_ems_instance
|
||||||
ev_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
ev_charge_hours = np.full(ems.config.prediction_hours, 1.0)
|
||||||
ems.set_ev_charge_hours(ev_charge_hours)
|
ems.set_ev_charge_hours(ev_charge_hours)
|
||||||
assert np.array_equal(
|
assert np.array_equal(ems.ev_charge_hours, ev_charge_hours), (
|
||||||
ems.ev_charge_hours, ev_charge_hours
|
"EV charge hours should be set correctly"
|
||||||
), "EV charge hours should be set correctly"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_reset(create_ems_instance):
|
def test_reset(create_ems_instance):
|
||||||
@ -316,9 +316,9 @@ def test_reset(create_ems_instance):
|
|||||||
ems = create_ems_instance
|
ems = create_ems_instance
|
||||||
ems.reset()
|
ems.reset()
|
||||||
assert ems.ev.current_soc_percentage() == 100, "EV SOC should be reset to initial value"
|
assert ems.ev.current_soc_percentage() == 100, "EV SOC should be reset to initial value"
|
||||||
assert (
|
assert ems.battery.current_soc_percentage() == 80, (
|
||||||
ems.battery.current_soc_percentage() == 80
|
"Battery SOC should be reset to initial value"
|
||||||
), "Battery SOC should be reset to initial value"
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_simulate_start_now(create_ems_instance):
|
def test_simulate_start_now(create_ems_instance):
|
||||||
|
@ -588,9 +588,9 @@ class TestDataProvider:
|
|||||||
"""Test that DataProvider enforces singleton behavior."""
|
"""Test that DataProvider enforces singleton behavior."""
|
||||||
instance1 = provider
|
instance1 = provider
|
||||||
instance2 = DerivedDataProvider()
|
instance2 = DerivedDataProvider()
|
||||||
assert (
|
assert instance1 is instance2, (
|
||||||
instance1 is instance2
|
"Singleton pattern is not enforced; instances are not the same."
|
||||||
), "Singleton pattern is not enforced; instances are not the same."
|
)
|
||||||
|
|
||||||
def test_update_method_with_defaults(self, provider, sample_start_datetime, monkeypatch):
|
def test_update_method_with_defaults(self, provider, sample_start_datetime, monkeypatch):
|
||||||
"""Test the `update` method with default parameters."""
|
"""Test the `update` method with default parameters."""
|
||||||
@ -608,9 +608,9 @@ class TestDataProvider:
|
|||||||
DerivedDataProvider.provider_updated = False
|
DerivedDataProvider.provider_updated = False
|
||||||
provider.update_data(force_enable=True)
|
provider.update_data(force_enable=True)
|
||||||
assert provider.enabled() is False, "Provider should be disabled, but enabled() is True."
|
assert provider.enabled() is False, "Provider should be disabled, but enabled() is True."
|
||||||
assert (
|
assert DerivedDataProvider.provider_updated is True, (
|
||||||
DerivedDataProvider.provider_updated is True
|
"Provider should have been executed, but was not."
|
||||||
), "Provider should have been executed, but was not."
|
)
|
||||||
|
|
||||||
def test_delete_by_datetime(self, provider, sample_start_datetime):
|
def test_delete_by_datetime(self, provider, sample_start_datetime):
|
||||||
"""Test `delete_by_datetime` method for removing records by datetime range."""
|
"""Test `delete_by_datetime` method for removing records by datetime range."""
|
||||||
@ -625,12 +625,12 @@ class TestDataProvider:
|
|||||||
start_datetime=sample_start_datetime - to_duration("2 hours"),
|
start_datetime=sample_start_datetime - to_duration("2 hours"),
|
||||||
end_datetime=sample_start_datetime + to_duration("2 hours"),
|
end_datetime=sample_start_datetime + to_duration("2 hours"),
|
||||||
)
|
)
|
||||||
assert (
|
assert len(provider.records) == 1, (
|
||||||
len(provider.records) == 1
|
"Only one record should remain after deletion by datetime."
|
||||||
), "Only one record should remain after deletion by datetime."
|
)
|
||||||
assert provider.records[0].date_time == sample_start_datetime - to_duration(
|
assert provider.records[0].date_time == sample_start_datetime - to_duration("3 hours"), (
|
||||||
"3 hours"
|
"Unexpected record remains."
|
||||||
), "Unexpected record remains."
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDataImportProvider:
|
class TestDataImportProvider:
|
||||||
|
@ -151,9 +151,9 @@ class TestPredictionProvider:
|
|||||||
"""Test that PredictionProvider enforces singleton behavior."""
|
"""Test that PredictionProvider enforces singleton behavior."""
|
||||||
instance1 = provider
|
instance1 = provider
|
||||||
instance2 = DerivedPredictionProvider()
|
instance2 = DerivedPredictionProvider()
|
||||||
assert (
|
assert instance1 is instance2, (
|
||||||
instance1 is instance2
|
"Singleton pattern is not enforced; instances are not the same."
|
||||||
), "Singleton pattern is not enforced; instances are not the same."
|
)
|
||||||
|
|
||||||
def test_update_computed_fields(self, provider, sample_start_datetime):
|
def test_update_computed_fields(self, provider, sample_start_datetime):
|
||||||
"""Test that computed fields `end_datetime` and `keep_datetime` are correctly calculated."""
|
"""Test that computed fields `end_datetime` and `keep_datetime` are correctly calculated."""
|
||||||
@ -169,12 +169,12 @@ class TestPredictionProvider:
|
|||||||
provider.config.prediction_historic_hours * 3600
|
provider.config.prediction_historic_hours * 3600
|
||||||
)
|
)
|
||||||
|
|
||||||
assert (
|
assert provider.end_datetime == expected_end_datetime, (
|
||||||
provider.end_datetime == expected_end_datetime
|
"End datetime is not calculated correctly."
|
||||||
), "End datetime is not calculated correctly."
|
)
|
||||||
assert (
|
assert provider.keep_datetime == expected_keep_datetime, (
|
||||||
provider.keep_datetime == expected_keep_datetime
|
"Keep datetime is not calculated correctly."
|
||||||
), "Keep datetime is not calculated correctly."
|
)
|
||||||
|
|
||||||
def test_update_method_with_defaults(
|
def test_update_method_with_defaults(
|
||||||
self, provider, sample_start_datetime, config_eos, monkeypatch
|
self, provider, sample_start_datetime, config_eos, monkeypatch
|
||||||
@ -214,9 +214,9 @@ class TestPredictionProvider:
|
|||||||
DerivedPredictionProvider.provider_updated = False
|
DerivedPredictionProvider.provider_updated = False
|
||||||
provider.update_data(force_enable=True)
|
provider.update_data(force_enable=True)
|
||||||
assert provider.enabled() is False, "Provider should be disabled, but enabled() is True."
|
assert provider.enabled() is False, "Provider should be disabled, but enabled() is True."
|
||||||
assert (
|
assert DerivedPredictionProvider.provider_updated is True, (
|
||||||
DerivedPredictionProvider.provider_updated is True
|
"Provider should have been executed, but was not."
|
||||||
), "Provider should have been executed, but was not."
|
)
|
||||||
|
|
||||||
def test_delete_by_datetime(self, provider, sample_start_datetime):
|
def test_delete_by_datetime(self, provider, sample_start_datetime):
|
||||||
"""Test `delete_by_datetime` method for removing records by datetime range."""
|
"""Test `delete_by_datetime` method for removing records by datetime range."""
|
||||||
@ -231,12 +231,12 @@ class TestPredictionProvider:
|
|||||||
start_datetime=sample_start_datetime - to_duration("2 hours"),
|
start_datetime=sample_start_datetime - to_duration("2 hours"),
|
||||||
end_datetime=sample_start_datetime + to_duration("2 hours"),
|
end_datetime=sample_start_datetime + to_duration("2 hours"),
|
||||||
)
|
)
|
||||||
assert (
|
assert len(provider.records) == 1, (
|
||||||
len(provider.records) == 1
|
"Only one record should remain after deletion by datetime."
|
||||||
), "Only one record should remain after deletion by datetime."
|
)
|
||||||
assert provider.records[0].date_time == sample_start_datetime - to_duration(
|
assert provider.records[0].date_time == sample_start_datetime - to_duration("3 hours"), (
|
||||||
"3 hours"
|
"Unexpected record remains."
|
||||||
), "Unexpected record remains."
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestPredictionContainer:
|
class TestPredictionContainer:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user