def test_get_obssumm_file_timerange_warnings(mock_get_obssum_filename, mock_urlretrieve, two_days_timerange): """ Even though `get_obssum_filename` returns more than one file. Make sure that `get_obssumm_file` only attempts to retrieve the first one. """ rhessi.get_obssumm_file(two_days_timerange) mock_urlretrieve.assert_called_with('http://first.org/file.txt')
def test_get_obssumm_file_timerange_warnings(mock_get_obssum_filename, mock_urlretrieve, one_day_timerange, two_days_timerange): """ With only one day in the time range, the `UserWarning` should *not* be issued. With two days in the time range, the `UserWarning` should be issued. Only interested in the presence/absence of the `UserWarning`, *not* the return value of `get_obssumm_file`. """ with warnings.catch_warnings(record=True) as caught_warnings: rhessi.get_obssumm_file(one_day_timerange) assert len(caught_warnings) == 0 with pytest.warns(UserWarning): rhessi.get_obssumm_file(two_days_timerange)
def test_get_parse_obssum_file(): f = rhessi.get_obssumm_file(('2011/04/04', '2011/04/05')) header, _data = rhessi.parse_obssumm_file(f[0]) assert header.get('DATE_OBS') == '2011-04-04T00:00:00.000' assert header.get('DATE_END') == '2011-04-05T00:00:00.000' assert header.get('TELESCOP') == 'HESSI'
def test_get_parse_obssum_file(): f = rhessi.get_obssumm_file(('2011/04/04', '2011/04/05')) # doctest: +SKIP header, _data = rhessi.parse_obssumm_file(f[0]) assert header.get('DATE_OBS') == '2011-04-04T00:00:00.000' assert header.get('DATE_END') == '2011-04-05T00:00:00.000' assert header.get('TELESCOP') == 'HESSI'