Skip to content

Commit 6879c3a

Browse files
committed
fix mypy errors in test_predictor.py
1 parent 284c219 commit 6879c3a

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

tests/test_predictor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def setUp(self) -> None:
119119
}
120120
)
121121
# Pre-built mock app so load_compass_app() is never called
122-
self.predictor.app = MagicMock()
122+
self.mock_app = MagicMock()
123+
self.predictor.app = self.mock_app
123124

124125
# Link results returned by the mocked _match_shapes_to_network
125126
self._link_results = pd.DataFrame({"shape_id": ["SH1"], "edge_id": [1001]})
@@ -169,7 +170,7 @@ def test_beb_mpge_calculation(self) -> None:
169170
"""MPGe for a Battery Electric Bus equals miles / (kWh / KWH_PER_GGE)."""
170171
energy_kwh = KWH_PER_GGE # exactly 1 GGE, so mpge == distance in miles
171172
distance_miles = 10.0
172-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
173+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
173174
energy_value=energy_kwh,
174175
distance_value=distance_miles,
175176
energy_field="trip_energy_electric",
@@ -192,7 +193,7 @@ def test_diesel_mpge_calculation(self) -> None:
192193
"""MPGe for a Diesel Bus equals miles / (gallons * GGE_PER_GALLON_DIESEL)."""
193194
energy_gallons = 2.0
194195
distance_miles = 10.0
195-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
196+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
196197
energy_value=energy_gallons,
197198
distance_value=distance_miles,
198199
energy_field="trip_energy_liquid",
@@ -212,7 +213,7 @@ def test_diesel_mpge_calculation(self) -> None:
212213

213214
def test_zero_energy_yields_nan_mpge(self) -> None:
214215
"""Zero energy consumption must produce NaN (not inf) MPGe."""
215-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
216+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
216217
energy_value=0.0,
217218
distance_value=10.0,
218219
energy_field="trip_energy_electric",
@@ -229,7 +230,7 @@ def test_zero_energy_yields_nan_mpge(self) -> None:
229230

230231
def test_negative_energy_yields_nan_mpge(self) -> None:
231232
"""Negative energy consumption must produce NaN MPGe."""
232-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
233+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
233234
energy_value=-5.0,
234235
distance_value=10.0,
235236
energy_field="trip_energy_electric",
@@ -246,7 +247,7 @@ def test_negative_energy_yields_nan_mpge(self) -> None:
246247

247248
def test_irrelevant_columns_dropped(self) -> None:
248249
"""service_id, route_short_name, route_desc, route_type must not appear in results."""
249-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
250+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
250251
energy_value=KWH_PER_GGE,
251252
distance_value=10.0,
252253
energy_field="trip_energy_electric",
@@ -260,7 +261,7 @@ def test_irrelevant_columns_dropped(self) -> None:
260261

261262
def test_core_columns_preserved(self) -> None:
262263
"""trip_id, energy_used, miles, mpge, and energy_unit must be present in results."""
263-
self.predictor.app.run_calculate_path.return_value = self._make_compass_result(
264+
self.mock_app.run_calculate_path.return_value = self._make_compass_result(
264265
energy_value=KWH_PER_GGE,
265266
distance_value=10.0,
266267
energy_field="trip_energy_electric",

0 commit comments

Comments
 (0)