예제 #1
0
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'
예제 #2
0
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
예제 #3
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)
예제 #4
0
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
예제 #5
0
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
예제 #6
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'
예제 #7
0
파일: test_jsoc.py 프로젝트: zflamig/sunpy
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
예제 #8
0
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)
예제 #9
0
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'
예제 #10
0
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
예제 #11
0
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
예제 #12
0
파일: test_jsoc.py 프로젝트: zflamig/sunpy
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)
예제 #13
0
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'])
예제 #14
0
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'
예제 #15
0
파일: test_attr.py 프로젝트: zimmaz/sunpy
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')