Skip to content

Commit

Permalink
adds tank tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed Nov 16, 2024
1 parent 670220d commit 208ab37
Showing 1 changed file with 68 additions and 2 deletions.
70 changes: 68 additions & 2 deletions tests/test_routes/test_motors_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_create_motor_optional_params(stub_motor):
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def create_generic_motor(stub_motor):
def test_create_generic_motor(stub_motor):
stub_motor.update(
{
'chamber_radius': 0,
Expand Down Expand Up @@ -174,7 +174,7 @@ def create_generic_motor(stub_motor):
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def create_liquid_motor_level_tank(stub_motor, stub_level_tank):
def test_create_liquid_motor_level_tank(stub_motor, stub_level_tank):
stub_motor.update({'tanks': [stub_level_tank]})
with patch.object(
MotorController,
Expand All @@ -196,6 +196,72 @@ def create_liquid_motor_level_tank(stub_motor, stub_level_tank):
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def test_create_liquid_motor_mass_flow_tank(stub_motor, stub_mass_flow_tank):
stub_motor.update({'tanks': [stub_mass_flow_tank]})
with patch.object(
MotorController,
'create_motor',
return_value=MotorCreated(motor_id='123'),
) as mock_create_motor:
with patch.object(
Motor, 'set_motor_kind', side_effect=None
) as mock_set_motor_kind:
response = client.post(
'/motors/', json=stub_motor, params={'motor_kind': 'LIQUID'}
)
assert response.status_code == 200
assert response.json() == {
'motor_id': '123',
'message': 'Motor successfully created',
}
mock_set_motor_kind.assert_called_once_with(MotorKinds.LIQUID)
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def test_create_liquid_motor_ullage_tank(stub_motor, stub_ullage_tank):
stub_motor.update({'tanks': [stub_ullage_tank]})
with patch.object(
MotorController,
'create_motor',
return_value=MotorCreated(motor_id='123'),
) as mock_create_motor:
with patch.object(
Motor, 'set_motor_kind', side_effect=None
) as mock_set_motor_kind:
response = client.post(
'/motors/', json=stub_motor, params={'motor_kind': 'LIQUID'}
)
assert response.status_code == 200
assert response.json() == {
'motor_id': '123',
'message': 'Motor successfully created',
}
mock_set_motor_kind.assert_called_once_with(MotorKinds.LIQUID)
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def test_create_liquid_motor_mass_tank(stub_motor, stub_mass_tank):
stub_motor.update({'tanks': [stub_mass_tank]})
with patch.object(
MotorController,
'create_motor',
return_value=MotorCreated(motor_id='123'),
) as mock_create_motor:
with patch.object(
Motor, 'set_motor_kind', side_effect=None
) as mock_set_motor_kind:
response = client.post(
'/motors/', json=stub_motor, params={'motor_kind': 'LIQUID'}
)
assert response.status_code == 200
assert response.json() == {
'motor_id': '123',
'message': 'Motor successfully created',
}
mock_set_motor_kind.assert_called_once_with(MotorKinds.LIQUID)
mock_create_motor.assert_called_once_with(Motor(**stub_motor))


def test_create_hybrid_motor(stub_motor, stub_level_tank):
stub_motor.update(
{
Expand Down

0 comments on commit 208ab37

Please sign in to comment.