Skip to content

Commit 18e298b

Browse files
MNT: refactor EmptyMotor properties to use funcify_method and add tests
1 parent 899292f commit 18e298b

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed

rocketpy/motors/empty_motor.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rocketpy.mathutils import Function
1+
from rocketpy.mathutils import Function, funcify_method
22
from rocketpy.motors.motor import Motor
33

44

@@ -37,41 +37,41 @@ def __init__(self):
3737
self.I_13 = Function(0)
3838
self.I_23 = Function(0)
3939

40-
@property
40+
@funcify_method("Time (s)", "Center of Propellant Mass (kg)", "linear", "zero")
4141
def center_of_propellant_mass(self):
42-
return Function(0, "Time (s)", "Center of Propellant Mass (kg)")
42+
return 0
4343

44-
@property
44+
@funcify_method("Time (s)", "Exhaust Velocity (m/s)", "linear", "zero")
4545
def exhaust_velocity(self):
46-
return Function(0, "Time (s)", "Exhaust Velocity (m/s)")
46+
return 0
4747

4848
@property
4949
def propellant_initial_mass(self):
5050
return 0
5151

52-
@property
52+
@funcify_method("Time (s)", "Propellant I_11 (kg m²)", "linear", "zero")
5353
def propellant_I_11(self):
54-
return Function(0, "Time (s)", "Propellant I_11 (kg m²)")
54+
return 0
5555

56-
@property
56+
@funcify_method("Time (s)", "Propellant I_12 (kg m²)", "linear", "zero")
5757
def propellant_I_12(self):
58-
return Function(0, "Time (s)", "Propellant I_12 (kg m²)")
58+
return 0
5959

60-
@property
60+
@funcify_method("Time (s)", "Propellant I_13 (kg m²)", "linear", "zero")
6161
def propellant_I_13(self):
62-
return Function(0, "Time (s)", "Propellant I_13 (kg m²)")
62+
return 0
6363

64-
@property
64+
@funcify_method("Time (s)", "Propellant I_22 (kg m²)", "linear", "zero")
6565
def propellant_I_22(self):
66-
return Function(0, "Time (s)", "Propellant I_22 (kg m²)")
66+
return 0
6767

68-
@property
68+
@funcify_method("Time (s)", "Propellant I_23 (kg m²)", "linear", "zero")
6969
def propellant_I_23(self):
70-
return Function(0, "Time (s)", "Propellant I_23 (kg m²)")
70+
return 0
7171

72-
@property
72+
@funcify_method("Time (s)", "Propellant I_33 (kg m²)", "linear", "zero")
7373
def propellant_I_33(self):
74-
return Function(0, "Time (s)", "Propellant I_33 (kg m²)")
74+
return 0
7575

7676
@property
7777
def structural_mass_ratio(self):

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"tests.fixtures.motor.liquid_fixtures",
99
"tests.fixtures.motor.hybrid_fixtures",
1010
"tests.fixtures.motor.solid_motor_fixtures",
11+
"tests.fixtures.motor.empty_motor_fixtures",
1112
"tests.fixtures.motor.tanks_fixtures",
1213
"tests.fixtures.motor.tank_geometry_fixtures",
1314
"tests.fixtures.motor.generic_motor_fixtures",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pytest
2+
3+
from rocketpy.motors.empty_motor import EmptyMotor
4+
5+
6+
@pytest.fixture
7+
def empty_motor():
8+
"""An example of an empty motor with zero thrust and mass.
9+
10+
Returns
11+
-------
12+
rocketpy.EmptyMotor
13+
"""
14+
return EmptyMotor()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from unittest.mock import patch
2+
3+
4+
@patch("matplotlib.pyplot.show")
5+
def test_empty_motor_info(mock_show, empty_motor): # pylint: disable=unused-argument
6+
"""Tests the LiquidMotor.all_info() method.
7+
8+
Parameters
9+
----------
10+
mock_show : mock
11+
Mock of the matplotlib.pyplot.show function.
12+
empty_motor : rocketpy.EmptyMotor
13+
The EmptyMotor object to be used in the tests.
14+
"""
15+
assert empty_motor.info() is None
16+
assert empty_motor.all_info() is None

0 commit comments

Comments
 (0)