def test_can_handle_query(time): ans1 = goes.XRSClient._can_handle_query(time, Instrument('XRS')) assert ans1 is True ans2 = goes.XRSClient._can_handle_query(time) assert ans2 is False ans3 = goes.XRSClient._can_handle_query(time, Instrument('eve')) assert ans3 is False
def test_can_handle_query(): ans1 = eve.EVEClient._can_handle_query(Time('2012/8/9', '2012/8/10'), Instrument('eve'), Level(0)) assert ans1 is True ans2 = eve.EVEClient._can_handle_query(Time('2012/7/7', '2012/7/7')) assert ans2 is False ans3 = eve.EVEClient._can_handle_query(Time('2012/8/9', '2012/8/10'), Instrument('eve'), Source('sdo')) assert ans3 is False
def test_can_handle_query(): ans1 = noaa.NOAAIndicesClient._can_handle_query( Time('2012/8/9', '2012/8/10'), Instrument('noaa-indices')) assert ans1 ans2 = noaa.NOAAIndicesClient._can_handle_query( Time('2012/7/7', '2012/7/7')) assert not ans2 ans3 = noaa.NOAAIndicesClient._can_handle_query( Time('2012/8/9', '2012/8/10'), Instrument('eve')) assert not ans3
def test_query(time): tr = TimeRange(time.start, time.end) if parse_time("1983-05-01") in tr: with pytest.raises(ValueError): LCClient.query(time, Instrument('goes')) else: qr1 = LCClient.query(time, Instrument('goes')) assert isinstance(qr1, QueryResponse) assert qr1.time_range().start == time.start assert qr1.time_range().end == time.end
def test_query(mock_search): qr1 = LCClient.search(Time('2012/8/9', '2012/8/10'), Instrument('noaa-indices')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 1 assert qr1.time_range().start == parse_time('2012/08/09') assert qr1.time_range().end == parse_time('2012/08/10')
def test_fetch_working(tmpdir): """ Tests if the online server for noaa is working. Uses the url : ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt """ qr1 = LCClient.search(Time('2012/10/4', '2012/10/6'), Instrument('noaa-indices')) # Mock QueryResponse object mock_qr = mock_query_object('2012/10/4', '2012/10/6') # Compare if two objects have the same attribute mock_qr = mock_qr[0] qr = qr1[0] assert mock_qr.source == qr.source assert mock_qr.provider == qr.provider assert mock_qr.physobs == qr.physobs assert mock_qr.instrument == qr.instrument assert mock_qr.url == qr.url assert mock_qr.time == qr.time # Assert if the timerange is same assert qr1.time_range() == TimeRange('2012/10/4', '2012/10/6') target_dir = tmpdir.mkdir("down") download_list = LCClient.fetch(qr1, path=target_dir) assert len(download_list) == len(qr1) assert download_list[0].split('/')[-1] == 'RecentIndices.txt'
def test_query(LCClient, time): qr1 = LCClient.search(time, Instrument('XRS')) assert isinstance(qr1, QueryResponse) # We only compare dates here as the start time of the qr will always be the # start of the day. assert qr1.time_range().start.date() == time.start.date() almost_day = datetime.timedelta(days=1, milliseconds=-1) end = datetime.datetime.combine(time.end.date(), datetime.time()) + almost_day assert qr1.time_range().end == end
def test_query(LCClient, time): qr1 = LCClient.search(time, Instrument('XRS')) assert isinstance(qr1, QueryResponse) # We only compare dates here as the start time of the qr will always be the # start of the day. assert qr1.time_range().start.strftime('%Y-%m-%d') == time.start.strftime('%Y-%m-%d') almost_day = TimeDelta(1*u.day - 1*u.millisecond) end = parse_time(time.end.strftime('%Y-%m-%d')) + almost_day assert is_time_equal(qr1.time_range().end, end)
def test_fido(mock_wait, mock_search, mock_enqueue): qr1 = Fido.search(Time('2012/10/4', '2012/10/6'), Instrument('noaa-indices')) Fido.fetch(qr1, path="/some/path/{file}") # Here we assert that the `fetch` function has called the parfive # Downloader.enqueue_file method with the correct arguments. Everything # that happens after this point should either be tested in the # GenericClient tests or in parfive itself. assert mock_enqueue.called_once_with( ("ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt", "/some/path/RecentIndices.txt"))
def test_query(time): qr1 = LCClient.search(time, Instrument('lyra')) assert isinstance(qr1, QueryResponse) assert qr1.time_range().start == time.start assert qr1.time_range().end == time.end
def test_can_handle_query(time): ans1 = lyra.LYRAClient._can_handle_query(time, Instrument('lyra')) assert ans1 is True ans2 = lyra.LYRAClient._can_handle_query(time) assert ans2 is False
assert ans1 is True ans2 = lyra.LYRAClient._can_handle_query(time) assert ans2 is False @given(time_attr()) def test_query(time): qr1 = LCClient.search(time, Instrument('lyra')) assert isinstance(qr1, QueryResponse) assert qr1.time_range().start == time.start assert qr1.time_range().end == time.end @pytest.mark.remote_data @pytest.mark.parametrize("time,instrument", [ (Time('2013/8/27', '2013/8/27'), Instrument('lyra')), (Time('2013/2/4', '2013/2/6'), Instrument('lyra')), ]) def test_get(time, instrument): qr1 = LCClient.search(time, instrument) res = LCClient.fetch(qr1) download_list = res.wait(progress=False) assert len(download_list) == len(qr1) @pytest.mark.remote_data @pytest.mark.parametrize( "time, instrument", [(a.Time('2012/10/4', '2012/10/6'), a.Instrument('lyra')), (a.Time('2013/10/5', '2013/10/7'), a.Instrument('lyra'))]) def test_fido(time, instrument):
def test_query(): qr1 = LCClient.search(Time('2012/8/9', '2012/8/10'), Instrument('eve')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 2 assert qr1.time_range().start == parse_time('2012/08/09') assert qr1.time_range().end == parse_time('2012/08/11') # includes end.
def test_can_handle_query(): ans1 = rhessi.RHESSIClient._can_handle_query(Time('2012/8/9', '2012/8/9'), Instrument('rhessi')) assert ans1 is True ans2 = rhessi.RHESSIClient._can_handle_query(Time('2013/2/7', '2013/2/7')) assert ans2 is False
def test_fido(time, instrument): qr = Fido.search(a.Time('2012/10/4', '2012/10/6'), Instrument('XRS')) assert isinstance(qr, UnifiedResponse) response = Fido.fetch(qr) assert len(response) == qr._numfile
def test_no_satellite(LCClient): with pytest.raises(ValueError): LCClient.search(Time("1950/01/01", "1950/02/02"), Instrument('XRS'))
def test_new_logic(): qr = LCClient.query(Time('2012/10/4', '2012/10/6'), Instrument('goes')) res = LCClient.get(qr) download_list = res.wait(progress=False) assert len(download_list) == len(qr)
def test_no_satellite(): with pytest.raises(ValueError): LCClient.query(Time("1950/01/01", "1950/02/02"), Instrument('goes'))
def test_new_logic(): qr = LCClient.search(Time('2012/10/4', '2012/10/6'), Instrument('XRS')) res = LCClient.fetch(qr) download_list = res.wait(progress=False) assert len(download_list) == len(qr)
def test_query(): qr1 = LCClient.query(Time('2011/4/9', '2011/4/10'), Instrument('rhessi')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 1 assert qr1.time_range().start == parse_time('2011/04/09') assert qr1.time_range().end == parse_time('2011/04/10')
almost_day = TimeDelta(1 * u.day - 1 * u.millisecond) end = parse_time(time.end.strftime('%Y-%m-%d')) + almost_day assert is_time_equal(qr1.time_range().end, end) def test_query_error(LCClient): times = [a.Time("1983-05-01", "1983-05-02")] for time in times: with pytest.raises(ValueError): LCClient.search(time, Instrument('XRS')) @pytest.mark.remote_data @pytest.mark.parametrize("time, instrument", [ (Time('1983/06/17', '1983/06/18'), Instrument('XRS')), (Time('2012/10/4', '2012/10/6'), Instrument('XRS')), ]) def test_get(LCClient, time, instrument): qr1 = LCClient.search(time, instrument) download_list = LCClient.fetch(qr1) assert len(download_list) == len(qr1) @pytest.mark.remote_data def test_new_logic(LCClient): qr = LCClient.search(Time('2012/10/4', '2012/10/6'), Instrument('XRS')) download_list = LCClient.fetch(qr) assert len(download_list) == len(qr)
def test_new_logic(LCClient): qr = LCClient.search(Time('2012/10/4', '2012/10/6'), Instrument('XRS')) download_list = LCClient.fetch(qr) assert len(download_list) == len(qr)
assert ans3 == False @pytest.mark.remote_data def test_query(): qr1 = LCClient.search(Time('2012/8/9', '2012/8/10'), Instrument('noaa-indices')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 1 assert qr1.time_range().start == parse_time('2012/08/09') assert qr1.time_range().end == parse_time('2012/08/10') @pytest.mark.remote_data @pytest.mark.parametrize("time, instrument", [ (Time('2012/11/27', '2012/11/27'), Instrument('noaa-indices')), (Time('2012/10/4', '2012/10/6'), Instrument('noaa-indices')), ]) def test_fetch(time, instrument): qr1 = LCClient.search(time, instrument) res = LCClient.fetch(qr1) download_list = res.wait(progress=False) assert len(download_list) == len(qr1) @pytest.mark.remote_data @pytest.mark.parametrize( "time, instrument", [(a.Time("2012/10/4", "2012/10/6"), a.Instrument('noaa-indices')), (a.Time('2013/10/5', '2013/10/7'), a.Instrument('noaa-indices'))]) def test_fido(time, instrument):
Instrument('eve'), Source('sdo')) assert ans3 is False @pytest.mark.remote_data def test_query(): qr1 = LCClient.search(Time('2012/8/9', '2012/8/10'), Instrument('eve')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 2 assert qr1.time_range().start == parse_time('2012/08/09') assert qr1.time_range().end == parse_time('2012/08/11') # includes end. @pytest.mark.remote_data @pytest.mark.parametrize("time,instrument", [ (Time('2012/11/27', '2012/11/27'), Instrument('eve')), ]) def test_get(time, instrument): qr1 = LCClient.search(time, instrument) res = LCClient.fetch(qr1) download_list = res.wait(progress=False) assert len(download_list) == len(qr1) @pytest.mark.remote_data @pytest.mark.parametrize( 'query', [(a.Time('2012/10/4', '2012/10/6') & a.Instrument('eve') & a.Level(0))]) def test_fido(query): qr = Fido.search(query) client = qr.get_response(0).client
ans2 = rhessi.RHESSIClient._can_handle_query(Time('2013/2/7', '2013/2/7')) assert ans2 is False @pytest.mark.online def test_query(): qr1 = LCClient.query(Time('2011/4/9', '2011/4/10'), Instrument('rhessi')) assert isinstance(qr1, QueryResponse) assert len(qr1) == 1 assert qr1.time_range().start == parse_time('2011/04/09') assert qr1.time_range().end == parse_time('2011/04/10') @pytest.mark.online @pytest.mark.parametrize("time,instrument", [ (Time('2012/11/27', '2012/11/28'), Instrument('rhessi')), (Time('2012/10/4', '2012/10/5'), Instrument('rhessi')), ]) def test_get(time, instrument): qr1 = LCClient.query(time, instrument) res = LCClient.get(qr1) download_list = res.wait(progress=False) assert len(download_list) == len(qr1) @pytest.mark.online @pytest.mark.parametrize( "time, instrument", [(a.Time('2012/10/4', '2012/10/6'), a.Instrument('rhessi')), (a.Time('2013/10/5', '2013/10/7'), a.Instrument('rhessi'))]) def test_fido(time, instrument):
def test_query_error(LCClient): times = [a.Time("1983-05-01", "1983-05-02")] for time in times: with pytest.raises(ValueError): LCClient.search(time, Instrument('XRS'))
def test_fetch(mock_wait, mock_search): qr1 = LCClient.search(Time('2012/10/4', '2012/10/6'), Instrument('noaa-indices')) res = LCClient.fetch(qr1) download_list = res.wait(progress=False) assert len(download_list) == len(qr1)