Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ disable=raw-checker-failed,
method-cache-max-size-none,
no-else-raise, # pointless
unnecessary-lambda-assignment, # ruff already checks this
abstract-method, # NotImplementedError marks optional methods (polations, sensors, plots)



Expand Down
2 changes: 2 additions & 0 deletions rocketpy/environment/fetchers/elevation_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ def fetch_open_elevation(lat, lon):
except (
requests.exceptions.RequestException,
requests.exceptions.JSONDecodeError,
KeyError,
IndexError,
) as e:
raise RuntimeError("Unable to reach Open-Elevation API servers.") from e
3 changes: 1 addition & 2 deletions rocketpy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,8 +1203,7 @@ def wrapper(*args, **kwargs):
for i in range(max_attempts):
try:
return func(*args, **kwargs)
# pylint: disable=broad-except
except Exception as e: # pragma: no cover
except Exception as e: # pragma: no cover # pylint: disable=broad-exception-caught
if i == max_attempts - 1:
raise e from None
delay = min(delay * 2, max_delay)
Expand Down
10 changes: 6 additions & 4 deletions tests/fixtures/generic_surfaces/generic_surfaces_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@


@pytest.fixture(scope="session")
def filename_valid_coeff(tmpdir_factory):
def filename_valid_coeff(tmp_path_factory):
"""Creates temporary files used to test if generic surfaces
initializes correctly from CSV files"""
filename = tmpdir_factory.mktemp("aero_surface_data").join("valid_coefficients.csv")
filename = tmp_path_factory.mktemp("aero_surface_data").joinpath(
"valid_coefficients.csv"
)
pd.DataFrame(
{
"alpha": [0, 1, 2, 3, 0.1],
Expand All @@ -31,10 +33,10 @@ def filename_valid_coeff(tmpdir_factory):
},
)
)
def filename_invalid_coeff(tmpdir_factory, request):
def filename_invalid_coeff(tmp_path_factory, request):
"""Creates temporary CSV files used to test if generic surfaces
raises errors when initialized incorrectly from CSV files"""
filename = tmpdir_factory.mktemp("aero_surface_data").join(
filename = tmp_path_factory.mktemp("aero_surface_data").joinpath(
"tmp_invalid_coefficients.csv"
)
pd.DataFrame(request.param).to_csv(filename, index=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@


@pytest.fixture(scope="session")
def filename_valid_coeff_linear_generic_surface(tmpdir_factory):
def filename_valid_coeff_linear_generic_surface(tmp_path_factory):
"""Creates temporary files used to test if a linear generic surface
initializes correctly from CSV files"""
filename = tmpdir_factory.mktemp("aero_surface_data").join(
filename = tmp_path_factory.mktemp("aero_surface_data").joinpath(
"valid_coefficients_lgs.csv"
)
pd.DataFrame(
Expand All @@ -33,10 +33,10 @@ def filename_valid_coeff_linear_generic_surface(tmpdir_factory):
},
)
)
def filename_invalid_coeff_linear_generic_surface(tmpdir_factory, request):
def filename_invalid_coeff_linear_generic_surface(tmp_path_factory, request):
"""Creates temporary CSV files used to test if a linear generic surface
raises errors when initialized incorrectly from CSV files"""
filename = tmpdir_factory.mktemp("aero_surface_data").join(
filename = tmp_path_factory.mktemp("aero_surface_data").joinpath(
"tmp_invalid_coefficients_lgs.csv"
)
pd.DataFrame(request.param).to_csv(filename, index=False)
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/environment/test_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,14 @@ def test_resolve_noaa_collection_path_rejects_unknown_model():
"""Unknown shortcuts must fail with an actionable ValueError."""
with pytest.raises(ValueError, match="Unknown NOAA model collection"):
fetchers.resolve_noaa_collection_path("not-a-model")


def test_fetch_open_elevation_error_payload_raises_runtime_error(monkeypatch):
"""An error payload (no ``results``) must surface as the documented RuntimeError."""
payload = {"code": "temporarily_unavailable", "error": "Retry shortly."}
monkeypatch.setattr(
fetchers.requests, "get", lambda *a, **k: _FakeResponse(payload)
)
monkeypatch.setattr("rocketpy.tools.time.sleep", lambda _: None)
with pytest.raises(RuntimeError, match="Open-Elevation"):
fetchers.fetch_open_elevation(48.858844, 2.294351)
Loading