def test_get_obssumm_dbase_file_with_unsupported_start_time(unsupported_start_time): """ RHESSI summary files are not available for before 2002-02-01, ensure `ValueError` is raised. """ with pytest.raises(ValueError): rhessi.get_obssumm_dbase_file(unsupported_start_time)
def test_get_obssumm_dbase_file_with_unsupported_start_time( unsupported_start_time): """ RHESSI summary files are not available for before 2002-02-01, ensure `ValueError` is raised. """ with pytest.raises(ValueError): rhessi.get_obssumm_dbase_file(unsupported_start_time)
def test_get_obssumm_dbase_file_build_correct_url(mock_get_base_url, mock_urlretrieve, one_day_timerange): """ This test ensures that we build the correct url which is then used to get the database file. """ rhessi.get_obssumm_dbase_file(one_day_timerange) mock_urlretrieve.assert_called_with( 'http://www.example.com/dbase/hsi_obssumm_filedb_201601.txt')
def test_get_obssumm_dbase_file_build_correct_url(mock_get_base_url, mock_urlretrieve, one_day_timerange): """ This test ensures that we build the correct url which is then used to get the database file. """ rhessi.get_obssumm_dbase_file(one_day_timerange) mock_urlretrieve.assert_called_with( 'http://www.example.com/dbase/hsi_obssumm_filedb_201601.txt')
def test_get_obssumm_dbase_file_timerange_warnings(mock_get_base_url, 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_dbase_file`. """ with warnings.catch_warnings(record=True) as caught_warnings: rhessi.get_obssumm_dbase_file(one_day_timerange) assert len(caught_warnings) == 0 with pytest.warns(UserWarning): rhessi.get_obssumm_dbase_file(two_days_timerange)
def test_get_obssumm_dbase_file_timerange_warnings(mock_get_base_url, 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_dbase_file`. """ with warnings.catch_warnings(record=True) as caught_warnings: rhessi.get_obssumm_dbase_file(one_day_timerange) assert len(caught_warnings) == 0 with pytest.warns(UserWarning): rhessi.get_obssumm_dbase_file(two_days_timerange)
def test_parse_obssum_dbase_file(): file = rhessi.get_obssumm_dbase_file(('2011/04/04', '2011/04/05')) obssum = rhessi.parse_obssumm_dbase_file(file[0]) assert obssum['filename'][0] == 'hsi_obssumm_20110401_043.fit' assert obssum['filename'][-1] == 'hsi_obssumm_20110430_029.fit' assert obssum['orb_st'][0] == 0 assert obssum['orb_st'][-1] == 0 assert obssum['orb_end'][0] == 0 assert obssum['orb_end'][-1] == 0 assert obssum['start_time'][0] == datetime(2011, 4, 1, 0, 0, 0) assert obssum['start_time'][-1] == datetime(2011, 4, 30, 0, 0, 0) assert obssum['end_time'][0] == datetime(2011, 4, 2, 0, 0, 0) assert obssum['end_time'][-1] == datetime(2011, 5, 1, 0, 0, 0) assert obssum['status_flag'][0] == 0 assert obssum['status_flag'][-1] == 0 assert obssum['npackets'][0] == 0 assert obssum['npackets'][-1] == 0
def test_parse_obssum_dbase_file(): file = rhessi.get_obssumm_dbase_file(('2011/04/04', '2011/04/05')) obssum = rhessi.parse_obssumm_dbase_file(file[0]) assert obssum['filename'][0] == 'hsi_obssumm_20110401_043.fit' assert obssum['filename'][-1] == 'hsi_obssumm_20110430_029.fit' assert obssum['orb_st'][0] == 0 assert obssum['orb_st'][-1] == 0 assert obssum['orb_end'][0] == 0 assert obssum['orb_end'][-1] == 0 assert obssum['start_time'][0] == datetime(2011, 4, 1, 0, 0, 0) assert obssum['start_time'][-1] == datetime(2011, 4, 30, 0, 0, 0) assert obssum['end_time'][0] == datetime(2011, 4, 2, 0, 0, 0) assert obssum['end_time'][-1] == datetime(2011, 5, 1, 0, 0, 0) assert obssum['status_flag'][0] == 0 assert obssum['status_flag'][-1] == 0 assert obssum['npackets'][0] == 0 assert obssum['npackets'][-1] == 0
def test_get_obssumm_dbase_file(): with pytest.raises(ValueError): rhessi.get_obssumm_dbase_file(['2002/01/01', '2002/04/01'])
def test_get_obssumm_dbase_file(): with pytest.raises(ValueError): rhessi.get_obssumm_dbase_file(['2002/01/01', '2002/04/01'])