Skip to content

Commit

Permalink
More careful unit tests for observatory frametype
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Urban committed Apr 5, 2019
1 parent f2b9f1b commit ca4a2e0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gwdetchar/io/tests/test_datafind.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ def test_get_data_dict_from_NDS(tsdget):
nptest.assert_array_equal(data['X1:TEST-STRAIN'].value, HOFT.value)


@mock.patch('gwpy.timeseries.TimeSeries.read',
return_value=HOFT.crop(16, 48))
def test_get_data_from_cache(tsget):
@mock.patch('gwdatafind.find_urls')
@mock.patch('gwpy.timeseries.TimeSeries.read')
def test_get_data_from_cache(tsget, find_data):
# set return values
find_data.return_value = ['test.gwf']
tsget.return_value = HOFT.crop(16, 48)

# retrieve test frame
start = 16
end = start + 32
channel = 'X1:TEST-STRAIN'
data = datafind.get_data(channel, start, end, source=True)
frametype = 'X1_TEST'
data = datafind.get_data(channel, start, end, frametype=frametype)

# test data products
assert isinstance(data, TimeSeries)
Expand All @@ -109,13 +114,15 @@ def test_get_data_from_cache(tsget):
nptest.assert_array_equal(data.value, HOFT.crop(start, end).value)


@mock.patch('gwdatafind.find_urls')
@mock.patch('gwdetchar.io.datafind.remove_missing_channels')
@mock.patch('gwpy.timeseries.TimeSeriesDict.read')
def test_get_data_dict_from_cache(tsdget, remove):
def test_get_data_dict_from_cache(tsdget, remove, find_data):
# set return values
tsdget.return_value = TimeSeriesDict({
'X1:TEST-STRAIN': HOFT.crop(16, 48)})
remove.return_value = ['X1:TEST-STRAIN']
find_data.return_value = ['test.gwf']
# retrieve test frame
start = 16
end = start + 32
Expand Down

0 comments on commit ca4a2e0

Please sign in to comment.