def test_complexattr_and_duplicate(): attr = core_attrs.Time((2011, 1, 1), (2011, 1, 1, 1)) pytest.raises(TypeError, lambda: attr & core_attrs.Time((2011, 2, 1), (2011, 2, 1, 1))) attr |= a.Source('foo') pytest.raises(TypeError, lambda: attr & core_attrs.Time((2011, 2, 1), (2011, 2, 1, 1)))
def test_complexquery(): a1 = attrs.Series('foo1') a2 = attrs.Series('foo2') t1 = core_attrs.Time('2012/01/01', '2013/1/2') t2 = core_attrs.Time('2012/01/01', '2013/1/3') ans1 = jsoc.jsoc.and_(a1 | a2, t1 | t2) assert isinstance(ans1.attrs[0], AttrOr) assert isinstance(ans1.attrs[0].attrs[0], AttrAnd) assert isinstance(ans1.attrs[0].attrs[1], AttrAnd)
def test_incorrect_content_disposition(client): results = client.search( core_attrs.Time('2011/1/1 01:00', '2011/1/1 01:02'), core_attrs.Instrument('mdi')) files = client.fetch(results[0:1]) assert len(files) == 1 assert files[0].endswith("mdi_vw_v_9466622_9466622.tar") assert "Content" not in files[0]
def test_time_xor(): one = core_attrs.Time((2010, 1, 1), (2010, 1, 2)) a = one ^ core_attrs.Time((2010, 1, 1, 1), (2010, 1, 1, 2)) assert a == attr.AttrOr( [core_attrs.Time((2010, 1, 1), (2010, 1, 1, 1)), core_attrs.Time((2010, 1, 1, 2), (2010, 1, 2))]) a ^= core_attrs.Time((2010, 1, 1, 4), (2010, 1, 1, 5)) assert a == attr.AttrOr([ core_attrs.Time((2010, 1, 1), (2010, 1, 1, 1)), core_attrs.Time((2010, 1, 1, 2), (2010, 1, 1, 4)), core_attrs.Time((2010, 1, 1, 5), (2010, 1, 2)) ])
def test_path(client, tmpdir): """ Test that '{file}' is automatically appended to the end of a custom path if it is not specified. """ qr = client.search( core_attrs.Time('2011-06-07 06:33', '2011-06-07 06:33:08'), core_attrs.Instrument('aia'), core_attrs.Wavelength(171 * u.AA)) tmp_dir = tmpdir / "{file}" files = client.fetch(qr, path=tmp_dir) assert len(files) == 1 # The construction of a VSO filename is bonkers complex, so there is no # practical way to determine what it should be in this test, so we just # put it here. assert "aia_lev1_171a_2011_06_07t06_33_02_77z_image_lev1.fits" in files[0]
def test_vso_hmi(client, tmpdir): """ This is a regression test for https://github.com/sunpy/sunpy/issues/2284 """ res = client.search(core_attrs.Time('2017-09-02 23:52:00', '2017-09-02 23:54:00'), core_attrs.Instrument('HMI') | core_attrs.Instrument('AIA')) dr = client.make_getdatarequest(res) # Extract the DRIs from the request dris = dr.request.datacontainer.datarequestitem # 3 HMI series and one AIA assert len(dris) == 4 # For each DataRequestItem assert that there is only one series in it. for dri in dris: fileids = dri.fileiditem.fileid series = list(map(lambda x: x.split(':')[0], fileids)) assert all([s == series[0] for s in series])
def test_no_download(client): """ Test for https://github.com/sunpy/sunpy/issues/3292 """ class MockDownloader: download_called = False def __init__(self): pass def download(self, *args, **kwargs): self.download_called = True # this should fail stereo = (core_attrs.Detector('STEREO_B') & core_attrs.Instrument('EUVI') & core_attrs.Time('1900-01-01', '1900-01-01T00:10:00')) qr = client.search(stereo, response_format="table") downloader = MockDownloader() res = client.fetch(qr, wait=False, downloader=downloader) assert downloader.download_called is False assert res == Results()
def vso_time(self): return core_attrs.Time( Time.strptime(self['event_starttime'], "%Y-%m-%dT%H:%M:%S"), Time.strptime(self['event_endtime'], "%Y-%m-%dT%H:%M:%S"))
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_complexattr_or_eq(): attr = core_attrs.Time((2011, 1, 1), (2011, 1, 1, 1)) assert attr | attr == attr assert attr | core_attrs.Time((2011, 1, 1), (2011, 1, 1, 1)) == attr
def test_input_error(): with pytest.raises(ValueError): core_attrs.Time('2012/1/1')
def test_Time_timerange(): t = core_attrs.Time(TimeRange('2012/1/1', '2012/1/2')) assert isinstance(t, core_attrs.Time) assert t.min == parse_time((2012, 1, 1)) assert t.max == parse_time((2012, 1, 2))
def test_vso_error(client): with pytest.warns(SunpyUserWarning, match="VSO-C500 :soap:Server.Transport : 404 Not Found"): client.search(core_attrs.Time('2019/12/30', '2019/12/31'), core_attrs.Instrument('ovsa'))
def vso_time(self): return core_attrs.Time(self['event_starttime'], self['event_endtime'])