Skip to content

Commit 5b7447a

Browse files
committed
adding test for empty file
1 parent 8888b6a commit 5b7447a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mhkit/tests/test_wave.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from pandas.testing import assert_frame_equal
1111
import inspect
1212
from datetime import datetime
13+
import contextlib
14+
from io import StringIO
1315

1416

1517
testdir = dirname(abspath(__file__))
@@ -550,6 +552,14 @@ def test_ndbc_request_data_filenames_length(self):
550552
wave.io.ndbc.request_data('swden', pd.Series(dtype=float))
551553

552554
self.assertTrue('At least 1 filename must be passed' in str(context.exception))
555+
556+
def test_ndbc_request_data_empty_file(self):
557+
temp_stdout = StringIO()
558+
filename = pd.Series("42008h1984.txt.gz") # known empty file. If NDBC replaces, this test may fail.
559+
with contextlib.redirect_stdout(temp_stdout):
560+
wave.io.ndbc.request_data('stdmet', filename)
561+
output = temp_stdout.getvalue().strip()
562+
self.assertEqual(output, 'The NDBC file "' + filename.values +'" is empty or missing data. Please omit this file from your data request in the future.')
553563

554564
def test_ndbc_dates_to_datetime(self):
555565
dt = wave.io.ndbc.dates_to_datetime('swden', self.swden)

0 commit comments

Comments
 (0)