Skip to content

Commit 10509ae

Browse files
committed
fix: test failures — add pytest-asyncio config, skip guards for optional deps, soft-import geopandas
1 parent 396e95a commit 10509ae

5 files changed

Lines changed: 20 additions & 5 deletions

File tree

azure_handler/storage.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ def _resolve(self, path: str) -> Path:
5353
return full
5454

5555
def save_parquet(self, df: "pd.DataFrame", path: str) -> str:
56-
import geopandas as gpd
57-
5856
full = self._resolve(path)
5957

60-
if "latitude" in df.columns and "longitude" in df.columns:
58+
try:
59+
import geopandas as gpd
60+
except ImportError:
61+
gpd = None
62+
63+
if gpd and "latitude" in df.columns and "longitude" in df.columns:
6164
valid = df["latitude"].notna() & df["longitude"].notna()
6265
if valid.any():
6366
geometry = gpd.points_from_xy(
@@ -129,14 +132,18 @@ def _ensure_container(self, container: str) -> None:
129132

130133
def save_parquet(self, df: "pd.DataFrame", path: str) -> str:
131134
import tempfile
132-
import geopandas as gpd
135+
136+
try:
137+
import geopandas as gpd
138+
except ImportError:
139+
gpd = None
133140

134141
container = path.split("/")[0]
135142
blob_name = "/".join(path.split("/")[1:])
136143
self._ensure_container(container)
137144

138145
with tempfile.NamedTemporaryFile(suffix=".parquet", delete=True) as tmp:
139-
if "latitude" in df.columns and "longitude" in df.columns:
146+
if gpd and "latitude" in df.columns and "longitude" in df.columns:
140147
valid = df["latitude"].notna() & df["longitude"].notna()
141148
if valid.any():
142149
geometry = gpd.points_from_xy(

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
asyncio_mode = auto

test/test_adcp_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ def test_dimensions(self, adcp_raw_file):
6060
assert ds.sizes["range"] == 70
6161
assert ds.sizes["beam"] == 4
6262

63+
@pytest.mark.skipif(not HAS_DOLFYN, reason="dolfyn not installed")
6364
def test_file_not_found(self):
6465
from ingest.adcp_parser import read_rdi
6566

6667
with pytest.raises((FileNotFoundError, RuntimeError)):
6768
read_rdi(Path("/nonexistent/file.raw"))
6869

70+
@pytest.mark.skipif(not HAS_DOLFYN, reason="dolfyn not installed")
6971
def test_wrong_extension(self, tmp_path):
7072
from ingest.adcp_parser import read_rdi
7173

test/test_pipeline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from azure_handler.storage import LocalStorage
1212
from config import EdgeConfig
13+
from ingest.adapter import HAS_NMEA
1314
from process.pipeline import process_file
1415

1516

@@ -65,6 +66,7 @@ async def test_process_empty_csv(config, storage, tmp_path):
6566
# NMEA file processing
6667
# ------------------------------------------------------------------
6768

69+
@pytest.mark.skipif(not HAS_NMEA, reason="oceanstream NMEA parser not installed")
6870
@pytest.mark.asyncio
6971
async def test_process_nmea_file(config, storage, tmp_path):
7072
"""Process a small NMEA .txt file."""

test/test_stream_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66
import pandas as pd
77

8+
from ingest.adapter import HAS_NMEA
89
from ingest.stream_parser import (
910
detect_format,
1011
parse_csv_line,
@@ -39,6 +40,7 @@ def test_gn_prefix(self):
3940
# parse_nmea_line
4041
# ------------------------------------------------------------------
4142

43+
@pytest.mark.skipif(not HAS_NMEA, reason="oceanstream NMEA parser not installed")
4244
class TestParseNmeaLine:
4345
def test_gga_with_timestamp(self):
4446
line = "2024-02-17T00:00:01.346168Z $GPGGA,000000.00,3242.3916,N,11714.1640,W,1,10,0.8,10.2,M,-34.3,M,,*66"

0 commit comments

Comments
 (0)