Skip to content

Commit ac0ddc9

Browse files
tpd-opitzLKuemmel
andcommitted
Remove failsafe access to new key
Co-authored-by: LKuemmel <76958050+LKuemmel@users.noreply.github.com>
1 parent d550960 commit ac0ddc9

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/config.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ def __init__(self,
99
self.default_price = default_price
1010
self.tariffs = tariffs if tariffs is not None else []
1111
self.update_hours = update_hours if update_hours is not None else list(range(24))
12-
13-
# Process tariffs to ensure weekdays list is present
14-
for tariff in self.tariffs:
15-
if "active_times" in tariff and "weekdays" not in tariff["active_times"]:
16-
tariff["active_times"]["weekdays"] = list(range(7)) # Default to all weekdays
17-
1812
'''
1913
Example configuration:
2014
"tariffs": [

packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ def _fetch_price_for_time_slot(config: FixedHoursTariffConfiguration,
7676
(_to_date(start, time_slot), _to_date(end, time_slot))
7777
for start, end in tariff["active_times"]["dates"]
7878
]
79-
# If no weekdays specified, assume all days are active
80-
weekdays = tariff["active_times"]["weekdays"] or range(7)
79+
weekdays = tariff["active_times"]["weekdays"]
8180
if (any(start <= time_slot.time() < end for start, end in active_times) and
8281
any(start <= time_slot.date() <= end for start, end in active_dates) and
8382
time_slot.weekday() in weekdays):

packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class TestValidateTariffTimes:
9696
"active_times": {
9797
"dates": [("01-01", "31-12")],
9898
"times": [("08:00", "12:00")],
99+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
99100
},
100101
},
101102
{
@@ -104,6 +105,7 @@ class TestValidateTariffTimes:
104105
"active_times": {
105106
"dates": [("01-01", "31-12")],
106107
"times": [("14:00", "18:00")],
108+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
107109
},
108110
},
109111
],
@@ -119,6 +121,7 @@ class TestValidateTariffTimes:
119121
"active_times": {
120122
"dates": [("01-01", "31-12")],
121123
"times": [("08:00", "12:00")],
124+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
122125
},
123126
},
124127
{
@@ -127,6 +130,7 @@ class TestValidateTariffTimes:
127130
"active_times": {
128131
"dates": [("01-01", "31-12")],
129132
"times": [("12:00", "14:00")],
133+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
130134
},
131135
},
132136
],
@@ -216,6 +220,7 @@ class TestFetch:
216220
"active_times": {
217221
"dates": [("01-01", "31-12")],
218222
"times": [("00:00", "24:00")],
223+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
219224
},
220225
}
221226
],
@@ -232,6 +237,7 @@ class TestFetch:
232237
"active_times": {
233238
"dates": [("01-01", "31-12")],
234239
"times": [("00:00", "24:00")],
240+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
235241
},
236242
}
237243
],
@@ -273,6 +279,7 @@ def test_fetch_price_configurations(self, default_price, tariffs, expected_price
273279
"active_times": {
274280
"dates": [("01-01", "31-12")],
275281
"times": [("00:00", "24:00")],
282+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
276283
},
277284
}
278285
],
@@ -323,6 +330,7 @@ class TestCreateElectricityTariff:
323330
"active_times": {
324331
"dates": [("01-01", "31-12")],
325332
"times": [("00:00", "24:00")],
333+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
326334
},
327335
}
328336
],
@@ -339,6 +347,7 @@ class TestCreateElectricityTariff:
339347
"active_times": {
340348
"dates": [("01-01", "31-12")],
341349
"times": [("00:00", "24:00")],
350+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
342351
},
343352
}
344353
],
@@ -354,6 +363,7 @@ class TestCreateElectricityTariff:
354363
"active_times": {
355364
"dates": [("01-01", "01-01")],
356365
"times": [("00:00", "00:00")],
366+
"weekdays": [0, 1, 2, 3, 4, 5, 6],
357367
},
358368
}
359369
],

0 commit comments

Comments
 (0)