mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-08-25 15:01:14 +00:00
Ruff format
This commit is contained in:
@@ -20,9 +20,7 @@ class TestPVAkku(unittest.TestCase):
|
||||
min_soc_prozent=self.min_soc_prozent,
|
||||
max_soc_prozent=self.max_soc_prozent,
|
||||
)
|
||||
self.assertEqual(
|
||||
akku.ladezustand_in_prozent(), 50.0, "Initial SoC should be 50%"
|
||||
)
|
||||
self.assertEqual(akku.ladezustand_in_prozent(), 50.0, "Initial SoC should be 50%")
|
||||
|
||||
def test_discharge_below_min_soc(self):
|
||||
akku = PVAkku(
|
||||
@@ -34,18 +32,14 @@ class TestPVAkku(unittest.TestCase):
|
||||
)
|
||||
akku.reset()
|
||||
# Try to discharge more energy than available above min_soc
|
||||
abgegeben_wh, verlust_wh = akku.energie_abgeben(
|
||||
5000, 0
|
||||
) # Try to discharge 5000 Wh
|
||||
abgegeben_wh, verlust_wh = akku.energie_abgeben(5000, 0) # Try to discharge 5000 Wh
|
||||
expected_soc = self.min_soc_prozent # SoC should not drop below min_soc
|
||||
self.assertEqual(
|
||||
akku.ladezustand_in_prozent(),
|
||||
expected_soc,
|
||||
"SoC should not drop below min_soc after discharge",
|
||||
)
|
||||
self.assertEqual(
|
||||
abgegeben_wh, 2640.0, "The energy discharged should be limited by min_soc"
|
||||
)
|
||||
self.assertEqual(abgegeben_wh, 2640.0, "The energy discharged should be limited by min_soc")
|
||||
|
||||
def test_charge_above_max_soc(self):
|
||||
akku = PVAkku(
|
||||
@@ -64,9 +58,7 @@ class TestPVAkku(unittest.TestCase):
|
||||
expected_soc,
|
||||
"SoC should not exceed max_soc after charge",
|
||||
)
|
||||
self.assertEqual(
|
||||
geladen_wh, 3000.0, "The energy charged should be limited by max_soc"
|
||||
)
|
||||
self.assertEqual(geladen_wh, 3000.0, "The energy charged should be limited by max_soc")
|
||||
|
||||
def test_charging_at_max_soc(self):
|
||||
akku = PVAkku(
|
||||
@@ -97,9 +89,7 @@ class TestPVAkku(unittest.TestCase):
|
||||
akku.reset()
|
||||
# Try to discharge when SoC is already at min_soc
|
||||
abgegeben_wh, verlust_wh = akku.energie_abgeben(5000, 0)
|
||||
self.assertEqual(
|
||||
abgegeben_wh, 0.0, "No energy should be discharged when at min_soc"
|
||||
)
|
||||
self.assertEqual(abgegeben_wh, 0.0, "No energy should be discharged when at min_soc")
|
||||
self.assertEqual(
|
||||
akku.ladezustand_in_prozent(),
|
||||
self.min_soc_prozent,
|
||||
|
@@ -18,9 +18,7 @@ def create_ems_instance():
|
||||
Fixture to create an EnergieManagementSystem instance with given test parameters.
|
||||
"""
|
||||
# Initialize the battery and the inverter
|
||||
akku = PVAkku(
|
||||
kapazitaet_wh=5000, start_soc_prozent=80, hours=48, min_soc_prozent=10
|
||||
)
|
||||
akku = PVAkku(kapazitaet_wh=5000, start_soc_prozent=80, hours=48, min_soc_prozent=10)
|
||||
akku.reset()
|
||||
wechselrichter = Wechselrichter(10000, akku)
|
||||
|
||||
@@ -33,9 +31,7 @@ def create_ems_instance():
|
||||
home_appliance.set_startzeitpunkt(2)
|
||||
|
||||
# Example initialization of electric car battery
|
||||
eauto = PVAkku(
|
||||
kapazitaet_wh=26400, start_soc_prozent=10, hours=48, min_soc_prozent=10
|
||||
)
|
||||
eauto = PVAkku(kapazitaet_wh=26400, start_soc_prozent=10, hours=48, min_soc_prozent=10)
|
||||
|
||||
# Parameters based on previous example data
|
||||
pv_prognose_wh = [
|
||||
|
@@ -9,9 +9,7 @@ from akkudoktoreos.config import output_dir
|
||||
DIR_TESTDATA = Path(__file__).parent / "testdata"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"fn_in, fn_out", [("optimize_input_1.json", "optimize_result_1.json")]
|
||||
)
|
||||
@pytest.mark.parametrize("fn_in, fn_out", [("optimize_input_1.json", "optimize_result_1.json")])
|
||||
def test_optimize(fn_in, fn_out):
|
||||
# Load input and output data
|
||||
with open(DIR_TESTDATA / fn_in, "r") as f_in:
|
||||
@@ -26,9 +24,7 @@ def test_optimize(fn_in, fn_out):
|
||||
start_hour = 10
|
||||
|
||||
# Call the optimization function
|
||||
ergebnis = opt_class.optimierung_ems(
|
||||
parameter=input_data, start_hour=start_hour, ngen=3
|
||||
)
|
||||
ergebnis = opt_class.optimierung_ems(parameter=input_data, start_hour=start_hour, ngen=3)
|
||||
|
||||
# Assert that the output contains all expected entries.
|
||||
# This does not assert that the optimization always gives the same result!
|
||||
|
Reference in New Issue
Block a user