Skip to content

Commit ac7bd5e

Browse files
committed
Use benchmark all for rateacuity
1 parent 7b73430 commit ac7bd5e

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

tariff_fetch/_cli/rateacuity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def process_rateacuity(output_folder: Path, state: str, utility: Utility):
3131
with attempt, create_context() as context:
3232
with console.status("Fetching list of utilities..."):
3333
scraping_state = (
34-
LoginState(context).login(username, password).electric().benchmark().select_state(state.upper())
34+
LoginState(context).login(username, password).electric().benchmark_all().select_state(state.upper())
3535
)
3636
utilities = [_ for _ in scraping_state.get_utilities() if _]
3737

tariff_fetch/rateacuity/state.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,7 @@ def electric(self) -> ElectricState:
8787
return ElectricState(self._context)
8888

8989

90-
class ElectricState(State):
91-
def benchmark(self) -> ElectricBenchmarkStateDropdown:
92-
"""Switch the Electric report type to Benchmark and expose the state dropdown."""
93-
self._select_report("benchmark")
94-
return ElectricBenchmarkStateDropdown(self._context)
95-
90+
class SelectReportState(State):
9691
def _select_report(self, report: str):
9792
"""Click the given radio report selector if it is not already active."""
9893
radio = self._wait().until(
@@ -102,6 +97,17 @@ def _select_report(self, report: str):
10297
radio.click()
10398

10499

100+
class ElectricState(SelectReportState):
101+
def benchmark(self) -> ElectricBenchmarkStateDropdown:
102+
"""Switch the Electric report type to Benchmark and expose the state dropdown."""
103+
self._select_report("benchmark")
104+
return ElectricBenchmarkStateDropdown(self._context)
105+
106+
def benchmark_all(self) -> ElectricBenchmarkAllStateDropdown:
107+
self._select_report("benchall")
108+
return ElectricBenchmarkAllStateDropdown(self._context)
109+
110+
105111
class DropdownState(State):
106112
"""Shared behavior for dropdown-driven selections on the benchmark workflow."""
107113

@@ -163,6 +169,10 @@ class ElectricBenchmarkAllScheduleDropdown(ElectricBenchmarkAllUtilityDropdown):
163169
def get_schedules(self) -> list[str]:
164170
return self._visible_options()
165171

172+
def select_schedule(self, schedule: str) -> ElectricBenchmarkAllReport:
173+
"""Select a schedule and produce a report interface that can fetch data."""
174+
return self._select(schedule, category="Schedule", next_state=ElectricBenchmarkReport(self._context))
175+
166176

167177
class ElectricBenchmarkStateDropdown(DropdownState):
168178
element_id = "StateSelect"
@@ -246,6 +256,12 @@ def back_to_selections(self) -> ElectricBenchmarkScheduleDropdown:
246256
return self._back_to_selections(ElectricBenchmarkScheduleDropdown(self._context))
247257

248258

259+
class ElectricBenchmarkAllReport(ReportState):
260+
def back_to_selections(self) -> ElectricBenchmarkAllScheduleDropdown:
261+
"""Return to the selections page so additional schedules can be fetched."""
262+
return self._back_to_selections(ElectricBenchmarkAllScheduleDropdown(self._context))
263+
264+
249265
def _get_xlsx(folder) -> set[str]:
250266
"""Return the set of .xlsx filenames currently present in the provided folder."""
251267
return {_ for _ in os.listdir(folder) if _.endswith(".xlsx")}

0 commit comments

Comments
 (0)