def test_request_data_protocol(): responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) req = client.request_data(responses) req.wait() assert req._d['method'] == 'url' assert req._d['protocol'] == 'fits' responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**'), attrs.Protocol('fits')) req = client.request_data(responses) req.wait() assert req._d['method'] == 'url' assert req._d['protocol'] == 'fits' responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**'), attrs.Protocol('as-is')) req = client.request_data(responses) req.wait() assert req._d['method'] == 'url_quick' assert req._d['protocol'] == 'as-is'
def test_check_request(): responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) req = client.request_data(responses) req.wait() assert req.status == 0
def test_request_data_error(): responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**'), attrs.Protocol('foo')) with pytest.raises(TypeError): req = client.request_data(responses)
def test_wait_get(): responses = client.query(attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series( 'hmi.M_45s'), attrs.Notify('*****@*****.**')) path = tempfile.mkdtemp() res = client.get(responses, path=path) assert isinstance(res, Results) assert res.total == 1
def test_check_request(): responses = client.query( attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) req = client.request_data(responses) req.wait() assert client.check_request(req) == 0
def test_post_pass(): responses = client.search( vso_attrs.Time('2012/1/1T00:00:00', '2012/1/1T00:00:45'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) aa = client.request_data(responses) tmpresp = aa._d assert tmpresp['protocol'] == 'fits' assert tmpresp['method'] == 'url'
def test_wait_get(): responses = client.search( vso_attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) path = tempfile.mkdtemp() res = client.fetch(responses, path=path) assert isinstance(res, Results) assert len(res) == 1
def test_get_request(): responses = client.query(attrs.Time('2012/1/1T1:00:36', '2012/1/1T01:00:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) bb = client.request_data(responses) path = tempfile.mkdtemp() aa = client.get_request(bb, path=path) assert isinstance(aa, Results)
def test_post_pass(): responses = client.query(attrs.Time('2012/1/1T00:00:00', '2012/1/1T00:00:45'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) aa = client.request_data(responses, return_resp=True) tmpresp = aa[0].json() assert tmpresp['status'] == 2 assert tmpresp['protocol'] == 'FITS,compress Rice' assert tmpresp['method'] == 'url'
def test_post_fail(recwarn): res = client.query(attrs.Time('2012/1/1T00:00:00', '2012/1/1T00:00:45'), attrs.Series('none'), attrs.Notify('*****@*****.**')) client.request_data(res, return_resp=True) w = recwarn.pop(Warning) assert issubclass(w.category, Warning) assert "Query 0 returned status 4 with error Series none is not a valid series accessible from hmidb2." == str(w.message) assert w.filename assert w.lineno
def test_post_wavelength(): responses = client.query(attrs.Time('2010/07/30T13:30:00','2010/07/30T14:00:00'),attrs.Series('aia.lev1_euv_12s'), attrs.Wavelength(193*u.AA)|attrs.Wavelength(335*u.AA), attrs.Notify('*****@*****.**')) aa = client.request_data(responses, return_resp=True) tmpresp = aa[0].json() assert tmpresp['status'] == 2 assert tmpresp['protocol'] == 'FITS,compress Rice' assert tmpresp['method'] == 'url' assert tmpresp['rcount'] == 302
def test_results_filenames(): responses = client.search( vso_attrs.Time('2014/1/1T1:00:36', '2014/1/1T01:01:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) path = tempfile.mkdtemp() files = client.fetch(responses, path=path) assert isinstance(files, Results) assert len(files) == len(responses) for hmiurl in files: assert os.path.isfile(hmiurl)
def test_results_filenames(): responses = client.query(attrs.Time('2014/1/1T1:00:36', '2014/1/1T01:01:38'), attrs.Series('hmi.M_45s'), attrs.Notify('*****@*****.**')) path = tempfile.mkdtemp() aa = client.get(responses, path=path) assert isinstance(aa, Results) files = aa.wait() assert len(files) == len(responses) for hmiurl in aa.map_: assert os.path.basename(hmiurl) == os.path.basename(aa.map_[hmiurl]['path'])
def test_post_wavelength(): responses = client.search( vso_attrs.Time('2010/07/30T13:30:00', '2010/07/30T14:00:00'), attrs.Series('aia.lev1_euv_12s'), attrs.Wavelength(193 * u.AA) | attrs.Wavelength(335 * u.AA), attrs.Notify('*****@*****.**')) aa = client.request_data(responses) [r.wait() for r in aa] tmpresp = aa[0]._d assert tmpresp['protocol'] == 'fits' assert tmpresp['method'] == 'url' assert tmpresp['count'] == '302' tmpresp = aa[1]._d assert tmpresp['protocol'] == 'fits' assert tmpresp['method'] == 'url' assert tmpresp['count'] == '302'
import pytest import astropy.units as u import sunpy.net.jsoc as jsoc import sunpy.net.jsoc.attrs as attrs import sunpy.net.vso.attrs as vso_attrs from sunpy.net import _attrs as core_attrs from sunpy.net.attr import AttrOr, AttrAnd @pytest.mark.parametrize(("attr1, attr2"), [(attrs.Series('foo'), attrs.Series('boo')), (attrs.Protocol('a1'), attrs.Protocol('a2')), (attrs.Notify('*****@*****.**'), attrs.Notify('*****@*****.**'))]) def test_and(attr1, attr2): pytest.raises(TypeError, lambda: attr1 & attr2) def test_basicquery(): a1 = attrs.Series('foo') t1 = core_attrs.Time('2012/01/01', '2013/1/2') ans1 = jsoc.jsoc.and_(a1, t1) assert isinstance(ans1, AttrAnd) assert len(ans1.attrs) == 2 def test_mediumquery(): a1 = attrs.Series('foo1')