Skip to content

Commit

Permalink
Merge branch 'master' into update_storage_wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdiedrich authored Oct 16, 2024
2 parents 6346b87 + f368cb8 commit 13d583d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gsy_e/models/area/scm_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,11 @@ class AreaFees:

def prices_as_dict(self) -> Dict:
"""Return all prices (accumulated values) for the fees in a dictionary."""
return {
name: fee.price for name, fee in {**self.per_kWh_fees, **self.monthly_fees}.items()
}
# monthly fees are not accumulated but already set for the market slot,
# hence we only report the value of the FeeContainer here
monthly_prices = {name: fee.value for name, fee in self.monthly_fees.items()}
per_kwh_prices = {name: fee.price for name, fee in self.per_kWh_fees.items()}
return {**monthly_prices, **per_kwh_prices}

@property
def total_per_kWh_fee_price(self):
Expand Down
32 changes: 32 additions & 0 deletions tests/area/test_scm_data_classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from gsy_e.models.area.scm_dataclasses import AreaFees, FeeContainer


class TestAreaFees:
# pylint: disable=attribute-defined-outside-init

def setup_method(self):
self.area_fees = AreaFees(
grid_import_fee_const=0.2,
grid_export_fee_const=0.1,
grid_fees_reduction=0.0,
per_kWh_fees={
"taxes_surcharges": FeeContainer(value=0.01),
"other_fee": FeeContainer(value=0.001),
},
monthly_fees={
"monthly_fee": FeeContainer(value=0.002),
"other_monthly_fee": FeeContainer(value=0.0002),
},
)

def test_price_as_dict_returns_correct_values(self):
for fee in self.area_fees.per_kWh_fees.values():
fee.price = 0.1
for fee in self.area_fees.monthly_fees.values():
fee.price = 0.1
assert self.area_fees.prices_as_dict() == {
"taxes_surcharges": 0.1,
"other_fee": 0.1,
"monthly_fee": 0.002,
"other_monthly_fee": 0.0002,
}

0 comments on commit 13d583d

Please sign in to comment.