Skip to content

Commit

Permalink
test: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ADGEfficiency committed Sep 8, 2024
1 parent d042fc9 commit cff04fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion energypylinear/assets/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_custom_interval_data(kwargs: dict | None) -> list | None:
Returns:
A list of custom interval data, or `None` if no kwargs.
"""
if kwargs is None:
if (kwargs is None) or (kwargs == {}):
return None

custom_interval_data = []
Expand Down
15 changes: 14 additions & 1 deletion tests/assets/test_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ def test_price_optimization(
dispatch = charge - discharge
np.testing.assert_almost_equal(dispatch, expected_dispatch)

# now try the same with a spill asset
# this is just for test coverage really...
asset = epl.Battery(
power_mw=power_mw,
capacity_mwh=capacity_mwh,
efficiency_pct=efficiency,
electricity_prices=np.array(electricity_prices),
freq_mins=freq_mins,
initial_charge_mwh=initial_charge_mwh,
final_charge_mwh=0,
include_spill=True,
)
simulation = asset.optimize(verbose=False)


@pytest.mark.parametrize(
"carbon_intensities, initial_charge_mwh, expected_dispatch",
Expand Down Expand Up @@ -322,7 +336,6 @@ def test_no_simultaneous_import_export() -> None:
)
simulation = asset.optimize()
results = simulation.results

check_no_simultaneous(results, "site-import_power_mwh", "site-export_power_mwh")


Expand Down
3 changes: 3 additions & 0 deletions tests/assets/test_renewable_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ def test_interval_data() -> None:
electric_generation_lower_bound_pct=hypothesis.strategies.floats(
min_value=0, max_value=1.0
),
include_spill=hypothesis.strategies.booleans(),
)
def test_hypothesis(
idx_length: int,
prices_mu: float,
prices_std: float,
prices_offset: float,
electric_generation_lower_bound_pct: float,
include_spill: bool,
) -> None:
"""Test optimization with hypothesis."""
electricity_prices = (
Expand All @@ -144,5 +146,6 @@ def test_hypothesis(
electricity_prices=electricity_prices,
electric_generation_mwh=electric_generation_mwh,
electric_generation_lower_bound_pct=electric_generation_lower_bound_pct,
include_spill=include_spill,
)
asset.optimize(verbose=False)

0 comments on commit cff04fd

Please sign in to comment.