def test_fido(tmp_path, time, instrument, wave): with mock.patch('sunpy.net.Fido.search', return_value=UnifiedResponse(mock_query_object(time))): path = tmp_path / "sub" qr = Fido.search(time, instrument, wave) assert isinstance(qr, UnifiedResponse) with mock.patch('sunpy.net.Fido.fetch', return_value=UnifiedResponse(mock_query_object(time))): response = Fido.fetch(qr, path=path) assert len(response) == len(qr)
def test_path_format_keys(): t1 = QueryResponseTable({'Start Time': ['2011/01/01', '2011/01/02'], '!excite!': ['cat', 'rabbit'], '01 wibble': ['parsnip', 'door']}) assert t1.path_format_keys() == {'start_time', '_excite_', '01_wibble'} t2 = QueryResponseTable({'End Time': ['2011/01/01', '2011/01/02'], '!excite!': ['cat', 'rabbit']}) assert t2.path_format_keys() == {'_excite_', 'end_time'} unif = UnifiedResponse(t1, t2) assert unif.path_format_keys() == {'_excite_'}
def test_path_format_keys(): t1 = QueryResponseTable({'Start Time': ['2011/01/01', '2011/01/02'], '!excite!': ['cat', 'rabbit'], '01 wibble': ['parsnip', 'door']}) assert t1.path_format_keys() == {'start_time', '_excite_', '01_wibble'} t2 = QueryResponseTable({'End Time': ['2011/01/01', '2011/01/02'], '!excite!': ['cat', 'rabbit']}) assert t2.path_format_keys() == {'_excite_', 'end_time'} unif = UnifiedResponse(t1, t2) assert unif.path_format_keys() == {'_excite_'} with pytest.warns(SunpyDeprecationWarning): assert unif.response_block_properties() == {'_excite_'}
def test_vso_unifiedresponse(): vrep = vsoQueryResponse([]) vrep.client = True uresp = UnifiedResponse(vrep) assert isinstance(uresp, UnifiedResponse)
def test_vso_unifiedresponse(mock_build_client): vrep = VSOQueryResponseTable() vrep.client = True uresp = UnifiedResponse(vrep) assert isinstance(uresp, UnifiedResponse)
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') @mock.patch('sunpy.net.dataretriever.sources.noaa.NOAAIndicesClient.search', return_value=mock_query_object('2012/10/4', '2012/10/6')) @mock.patch('sunpy.net.download.Results.wait', return_value=['some/path/extension/RecentIndices.txt']) 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) @mock.patch('sunpy.net.fido_factory.Fido.fetch', side_effect=(UnifiedResponse( mock_query_object("2012/10/4", "2012/10/6")))) def test_fido(mock_fetch): qr = Fido.search(a.Time("2012/10/4", "2012/10/6"), a.Instrument('noaa-indices')) assert isinstance(qr, UnifiedResponse) response = Fido.fetch(qr) assert len(response) == qr._numfile