예제 #1
0
 def handle_gas(
     self, curr_gear: Gear, curr_rpm: EngineRPMS, pressure: GasPressure
 ) -> Gear:
     if curr_rpm.is_above(self._rpsm_range):
         return curr_gear.next()
     if curr_rpm.is_below(self._rpsm_range):
         return curr_gear.previous()
     return curr_gear
예제 #2
0
def test_strategy_sets_next_gear_when_rpms_above_range(mode):
    strategy = DrivingModeStrategy.create(driving_mode=mode,
                                          aggressive_mode=AggressiveMode.Mode1)
    curr_gear = Gear(gear=2)

    gear_to_set = strategy.handle_gas(curr_gear=curr_gear,
                                      curr_rpm=EngineRPMS(value=5000),
                                      pressure=GENTLE_PRESSURE)

    assert gear_to_set == curr_gear.next()
예제 #3
0
def assert_gear_was_increased(gearbox, initial_gear: Gear):
    assert gearbox.current_gear == initial_gear.next()