Skip to content

Commit 5d0de98

Browse files
committed
dev: add test for remote files
1 parent 61ad8a2 commit 5d0de98

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/gps_logger_parser/tests/test_parsers.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pyarrow as pa
55
import pyarrow.compute as pc
66
import pytest
7+
from upath import UPath
78

89
from ..gps.columns import GPS_HARMONIZED_COLUMN_TYPES, GPSHarmonizedColumn
910
from ..parser import detect_file
@@ -50,6 +51,17 @@
5051
(f.name, f) for f in (TESTS_DATA_PATH / "fail").iterdir() if not f.is_dir()
5152
]
5253

54+
testdata_s3 = []
55+
56+
S3_TEST_PATHS = TESTS_DATA_PATH / "s3.csv"
57+
if S3_TEST_PATHS.exists():
58+
with S3_TEST_PATHS.open("r") as f:
59+
import csv
60+
61+
reader = csv.DictReader(f, delimiter=";")
62+
for row in reader:
63+
testdata_s3.append((row["path"], row["endpoint_url"]))
64+
5365

5466
@pytest.mark.parametrize("file,path,file_format", testdata_success)
5567
def test_parser_success(file, path, file_format):
@@ -65,6 +77,13 @@ def test_parser_success(file, path, file_format):
6577
).as_py()
6678

6779

80+
@pytest.mark.parametrize("path,endpoint_url", testdata_s3)
81+
def test_parser_remote(path, endpoint_url):
82+
parser_instance = detect_file(UPath(path, anon=True, endpoint_url=endpoint_url))
83+
table = parser_instance.as_table()
84+
assert table
85+
86+
6887
@pytest.mark.parametrize("file,path", testdata_fail)
6988
def test_parser_fail(file, path):
7089
with pytest.raises(NotImplementedError):

0 commit comments

Comments
 (0)