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
3 changes: 3 additions & 0 deletions src/subscript/merge_rft_ertobs/merge_rft_ertobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
from os.path import abspath, isdir
from pathlib import Path
from typing import Tuple

Expand Down Expand Up @@ -154,6 +155,8 @@ def get_observations(obsdir: str = "", filepattern: str = "*.obs") -> pd.DataFra
""" # noqa
if "/" in filepattern:
raise ValueError("Do not include paths in filepattern")
if not isdir(obsdir):
raise ValueError(f'Observation directory "{abspath(obsdir)}" doesn\'t exist')

obs_dfs = []
for obsfilename in Path(obsdir).glob(filepattern):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_merge_rft_ertobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def fixture_drogondata(tmp_path):
os.chdir(cwd)


def test_invalid_obsdir():
"""Test exception when obsdir is not valid"""
with pytest.raises(ValueError, match="Observation directory"):
get_observations("/path/to/random/non-existing/directory")


def test_get_observations(drogondata):
"""Try to parse observations"""
dframe = get_observations("rft")
Expand Down