Skip to content

Commit

Permalink
fix: remove TrainFuel
Browse files Browse the repository at this point in the history
  • Loading branch information
redfrexx committed May 5, 2024
1 parent 74fea97 commit 0a42f4f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
10 changes: 0 additions & 10 deletions co2calculator/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
Size,
CarFuel,
BusFuel,
TrainFuel,
BusTrainRange,
FlightRange,
FlightClass,
FerryClass,
ElectricityFuel,
HeatingFuel,
Unit,
EmissionCategory,
)
from typing import Union
Expand All @@ -25,17 +23,9 @@ class TrainEmissionParameters(BaseModel):

category: TransportationMode = EmissionCategory.TRANSPORT
subcategory: TransportationMode = TransportationMode.TRAIN
fuel_type: Union[TrainFuel, str] = TrainFuel.AVERAGE
range: Union[BusTrainRange, str] = BusTrainRange.LONG_DISTANCE
size: Union[Size, str] = Size.AVERAGE

@validator("fuel_type", allow_reuse=True)
def check_fueltype(cls, v):
if isinstance(v, str):
assert v.lower() in (item.value for item in TrainFuel)
v = v.lower()
return TrainFuel(v)

@validator("range", allow_reuse=True)
def check_range(cls, v):
if isinstance(v, str):
Expand Down
1 change: 0 additions & 1 deletion tests/functional/test_data_code_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
emission_factors,
ElectricityFuel,
Size,
RangeCategory,
FlightClass,
FerryClass,
FlightRange,
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_calculate_mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ def test_calc_co2_bus(
pytest.param(1162, {}, 38.23, id="defaults on empty"),
pytest.param(
1162,
{"fuel_type": "electric", "vehicle_range": "long-distance"},
{"vehicle_range": "long-distance"},
37.18,
id="all optional arguments",
),
pytest.param(10, {"fuel_type": "diesel"}, 0.7, id="fuel_type: 'electric'"),
],
)
def test_calc_co2_train(
Expand Down

0 comments on commit 0a42f4f

Please sign in to comment.