Skip to content

Commit

Permalink
Add conftest and move fixture there (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsetiawan authored Aug 11, 2021
1 parent d888655 commit 5c100f4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 58 deletions.
34 changes: 34 additions & 0 deletions echopype/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""``pytest`` configuration."""

import pytest
from pathlib import Path

import fsspec


@pytest.fixture(scope="session")
def minio_bucket():
common_storage_options = dict(
client_kwargs=dict(endpoint_url="http://localhost:9000/"),
key="minioadmin",
secret="minioadmin",
)
bucket_name = "ooi-raw-data"
fs = fsspec.filesystem(
"s3",
**common_storage_options,
)
test_data = "data"
if not fs.exists(test_data):
fs.mkdir(test_data)

if not fs.exists(bucket_name):
fs.mkdir(bucket_name)

# Load test data into bucket
test_data_path = Path(__file__).parent.parent.joinpath(Path("test_data"))
for d in test_data_path.iterdir():
source_path = f'echopype/test_data/{d.name}'
fs.put(source_path, f'{test_data}/{d.name}', recursive=True)

return common_storage_options
28 changes: 0 additions & 28 deletions echopype/tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,6 @@ def _check_output_files(engine, output_files, storage_options):
fs.delete(output_files)


@pytest.fixture(scope="session")
def minio_bucket():
common_storage_options = dict(
client_kwargs=dict(endpoint_url="http://localhost:9000/"),
key="minioadmin",
secret="minioadmin",
)
bucket_name = "ooi-raw-data"
fs = fsspec.filesystem(
"s3",
**common_storage_options,
)
test_data = "data"
if not fs.exists(test_data):
fs.mkdir(test_data)

if not fs.exists(bucket_name):
fs.mkdir(bucket_name)

# Load test data into bucket
test_data_path = Path(__file__).parent.parent.joinpath(Path("test_data"))
for d in test_data_path.iterdir():
source_path = f'echopype/test_data/{d.name}'
fs.put(source_path, f'{test_data}/{d.name}', recursive=True)

return common_storage_options


@pytest.mark.parametrize("model", ["EK60"])
@pytest.mark.parametrize("file_format", [".zarr"])
@pytest.mark.parametrize(
Expand Down
30 changes: 0 additions & 30 deletions echopype/tests/test_echodata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from textwrap import dedent
from pathlib import Path

import fsspec

Expand All @@ -13,35 +12,6 @@
ek60_path = TEST_DATA_FOLDER / "ek60"


# TODO: Probably put the function below into a common module?
@pytest.fixture(scope="session")
def minio_bucket():
common_storage_options = dict(
client_kwargs=dict(endpoint_url="http://localhost:9000/"),
key="minioadmin",
secret="minioadmin",
)
bucket_name = "ooi-raw-data"
fs = fsspec.filesystem(
"s3",
**common_storage_options,
)
test_data = "data"
if not fs.exists(test_data):
fs.mkdir(test_data)

if not fs.exists(bucket_name):
fs.mkdir(bucket_name)

# Load test data into bucket
test_data_path = Path(__file__).parent.parent.joinpath(Path("test_data"))
for d in test_data_path.iterdir():
source_path = f'echopype/test_data/{d.name}'
fs.put(source_path, f'{test_data}/{d.name}', recursive=True)

return common_storage_options


class TestEchoData:
converted_zarr = (
ek60_path / "ncei-wcsd" / "Summer2017-D20170615-T190214.zarr"
Expand Down

0 comments on commit 5c100f4

Please sign in to comment.