Skip to content

Commit

Permalink
Deploy airbrakes after Motorburn
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil21 committed Sep 24, 2024
1 parent 2c34a36 commit 092aedd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions airbrakes/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def update(self):

def next_state(self):
self.context.state = FlightState(self.context)
# Deploy the airbrakes as soon as we enter the Flight state
self.context.set_airbrake_extension(1.0)


class FlightState(State):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ def test_name(self, motor_burn_state):
assert motor_burn_state.name == "MotorBurnState"

@pytest.mark.parametrize(
("avg_acceleration_mag", "current_speed", "max_speed", "expected_state"),
("avg_acceleration_mag", "current_speed", "max_speed", "expected_state", "airbrakes_ext"),
[
(0.0, 0.0, 0.0, MotorBurnState),
(0.0, 100.0, 100.0, FlightState),
(5.0, 50.0, 54.0, FlightState),
(7.0, 89.0, 89.0, MotorBurnState),
(6.0, 60.0, 60.0, FlightState),
(0.0, 0.0, 0.0, MotorBurnState, 0.0),
(0.0, 100.0, 100.0, FlightState, 1.0),
(5.0, 50.0, 54.0, FlightState, 1.0),
(7.0, 89.0, 89.0, MotorBurnState, 0.0),
(6.0, 60.0, 60.0, FlightState, 1.0),
],
ids=["at_launchpad", "faulty_speed", "decreasing_speed", "still_burning", "threshold"],
)
def test_update(self, motor_burn_state, avg_acceleration_mag, current_speed, max_speed, expected_state):
def test_update(self, motor_burn_state, avg_acceleration_mag, current_speed, max_speed, expected_state, airbrakes_ext):

Check failure on line 127 in tests/test_state.py

View workflow job for this annotation

GitHub Actions / build

Ruff (E501)

tests/test_state.py:127:121: E501 Line too long (123 > 120)
motor_burn_state.context.data_processor._avg_accel_mag = avg_acceleration_mag
motor_burn_state.context.data_processor._speed = current_speed
motor_burn_state.context.data_processor._max_speed = max_speed
motor_burn_state.update()
assert isinstance(motor_burn_state.context.state, expected_state)
assert motor_burn_state.context.current_extension == 0.0
assert motor_burn_state.context.current_extension == airbrakes_ext


class TestFlightState:
Expand Down

0 comments on commit 092aedd

Please sign in to comment.