Skip to content

Commit 142eaf8

Browse files
committed
Changes to conform to lint
1 parent d6c5dee commit 142eaf8

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

rocketpy/motors/motor.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,9 +1918,9 @@ def load_from_rse_file(
19181918
)
19191919

19201920
@staticmethod
1921-
def load_from_thrustcurve_api(name: str, **kwargs):
1921+
def call_thrustcurve_api(name: str):
19221922
"""
1923-
Creates a Motor instance by downloading a .eng file from the ThrustCurve API
1923+
Download a .eng file from the ThrustCurve API
19241924
based on the given motor name.
19251925
19261926
Parameters
@@ -1929,14 +1929,11 @@ def load_from_thrustcurve_api(name: str, **kwargs):
19291929
The motor name according to the API (e.g., "Cesaroni_M1670" or "M1670").
19301930
Both manufacturer-prefixed and shorthand names are commonly used; if multiple
19311931
motors match the search, the first result is used.
1932-
**kwargs :
1933-
Additional arguments passed to the Motor constructor or loader, such as
1934-
dry_mass, nozzle_radius, etc.
19351932
19361933
Returns
19371934
-------
1938-
instance : GenericMotor
1939-
A new GenericMotor instance initialized using the downloaded .eng file.
1935+
data_base64 : String
1936+
The .eng file of the motor in base64
19401937
19411938
Raises
19421939
------
@@ -1982,7 +1979,38 @@ def load_from_thrustcurve_api(name: str, **kwargs):
19821979
raise ValueError(
19831980
f"Downloaded .eng data for motor '{name}' is empty or invalid."
19841981
)
1982+
return data_base64
1983+
1984+
@staticmethod
1985+
def load_from_thrustcurve_api(name: str, **kwargs):
1986+
"""
1987+
Creates a Motor instance by downloading a .eng file from the ThrustCurve API
1988+
based on the given motor name.
1989+
1990+
Parameters
1991+
----------
1992+
name : str
1993+
The motor name according to the API (e.g., "Cesaroni_M1670" or "M1670").
1994+
Both manufacturer-prefixed and shorthand names are commonly used; if multiple
1995+
motors match the search, the first result is used.
1996+
**kwargs :
1997+
Additional arguments passed to the Motor constructor or loader, such as
1998+
dry_mass, nozzle_radius, etc.
1999+
2000+
Returns
2001+
-------
2002+
instance : GenericMotor
2003+
A new GenericMotor instance initialized using the downloaded .eng file.
2004+
2005+
Raises
2006+
------
2007+
ValueError
2008+
If no motor is found or if the downloaded .eng data is missing.
2009+
requests.exceptions.RequestException
2010+
If a network or HTTP error occurs during the API call.
2011+
"""
19852012

2013+
data_base64 = GenericMotor.call_thrustcurve_api(name)
19862014
data_bytes = base64.b64decode(data_base64)
19872015

19882016
# Step 3. Create the motor from the .eng file

tests/unit/motors/test_genericmotor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ def test_load_from_thrustcurve_api(monkeypatch, generic_motor):
229229
"""
230230

231231
class MockResponse:
232+
"""
233+
Class to Mock the API
234+
"""
232235
def __init__(self, json_data):
233236
self._json_data = json_data
234237

0 commit comments

Comments
 (0)