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
7 changes: 5 additions & 2 deletions rex/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,11 @@ def check_res_file(res_file):
raise FileInputError(msg)

else:
multi_h5_res, hsds = check_hsds_file(res_file)
bad = not hsds
try:
multi_h5_res, hsds = check_hsds_file(res_file)
bad = not hsds
except (OSError, ValueError): # cannot connect to HSDS
bad = True

if bad:
msg = ("{} is not a valid file path, and HSDS "
Expand Down
2 changes: 1 addition & 1 deletion rex/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""rex Version number"""

__version__ = "0.3.4"
__version__ = "0.3.5"
21 changes: 20 additions & 1 deletion tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas as pd
import pytest

from rex.utilities import parse_table
from rex.utilities import parse_table, check_res_file
from rex import TESTDATADIR

NSRDB_DIR = os.path.join(TESTDATADIR, 'nsrdb')
Expand Down Expand Up @@ -50,6 +50,25 @@ def test_parse_table():
parse_table([0, 1, 2])


def test_check_res_file_dne():
"""Test check_res_file() when file does not exist"""
with TemporaryDirectory() as td:
test_file = os.path.join(td, "gen.h5")

with pytest.raises(FileNotFoundError) as error:
check_res_file(test_file)

expected_msg = ("gen.h5 is not a valid file path, and HSDS cannot "
"be checked for a file at this path!")
assert expected_msg in str(error)

open(test_file, "w").close() # pylint: disable=consider-using-with
multi_file, hsds = check_res_file(test_file)

assert not multi_file
assert not hsds


def execute_pytest(capture='all', flags='-rapP'):
"""Execute module as pytest with detailed summary report.

Expand Down