def test_datasets(self): records = DALResults.from_result_url( 'http://example.com/query/dataset') record = records[0] assert record.getdataurl() == 'http://example.com/querydata/image.fits' dataset = record.getdataset() HDUList.fromstring(dataset.read())
def test_iter(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] record = list(iter(record)) assert record[0] == '1' assert record[1] == '2'
def test_iter(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') records = list(iter(dalresults)) _test_results(dalresults) _test_records(records)
def test_nodataset(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.getdataurl() is None with pytest.raises(KeyError): record.getdataset().read()
def test_iter(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] record = list(iter(record)) assert record[0] == '1' assert record[1] == '2'
def test_datasets(self): records = DALResults.from_result_url( 'http://example.com/query/dataset') record = records[0] assert record.getdataurl() == 'http://example.com/querydata/image.fits' dataset = record.getdataset() HDUList.fromstring(dataset.read())
def test_nodataset(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.getdataurl() is None with pytest.raises(KeyError): record.getdataset().read()
def test_iter(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') records = list(iter(dalresults)) _test_results(dalresults) _test_records(records)
def test_cachedataset(self, tmpdir): tmpdir = str(tmpdir) record = DALResults.from_result_url( 'http://example.com/query/dataset')[0] record.cachedataset(dir=tmpdir) assert "dataset.dat" in listdir(tmpdir)
def test_cachedataset(self, tmpdir): tmpdir = str(tmpdir) record = DALResults.from_result_url( 'http://example.com/query/dataset')[0] record.cachedataset(dir=tmpdir) assert "dataset.dat" in listdir(tmpdir)
def test_dataconsistency(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults['1'], np.ndarray) assert isinstance(dalresults['2'], np.ndarray) _test_results(dalresults) _test_records(dalresults)
def test_dataconsistency(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults['1'], np.ndarray) assert isinstance(dalresults['2'], np.ndarray) _test_results(dalresults) _test_records(dalresults)
def test_nosuchcolumn(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') with pytest.raises(KeyError): dalresults['nosuchcolumn'] with pytest.raises(KeyError): dalresults.getdesc('nosuchcolumn')
def test_itemaccess(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record['1'] == 23 assert record['2'] == b'Illuminatus' assert record['_1'] == 23 assert record['_2'] == b'Illuminatus'
def test_nosuchcolumn(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') with pytest.raises(KeyError): dalresults['nosuchcolumn'] with pytest.raises(KeyError): dalresults.getdesc('nosuchcolumn')
def test_itemaccess(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record['1'] == 23 assert record['2'] == b'Illuminatus' assert record['_1'] == 23 assert record['_2'] == b'Illuminatus'
def test_itemaccess(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record['1'] == 23 truth = b'Illuminatus' if ASTROPY_LT_4_1 else 'Illuminatus' assert record['2'] == truth assert record['_1'] == 23 assert record['_2'] == truth
def test_columnaliases(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.fieldname_with_ucd('foo') == '1' assert dalresults.fieldname_with_ucd('bar') == '1' assert dalresults.fieldname_with_utype('foobar') == '2' assert dalresults.fieldname_with_ucd('baz') is None assert dalresults.fieldname_with_utype('foobaz') is None
def test_columnaliases(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.fieldname_with_ucd('foo') == '1' assert dalresults.fieldname_with_ucd('bar') == '1' assert dalresults.fieldname_with_utype('foobar') == '2' assert dalresults.fieldname_with_ucd('baz') is None assert dalresults.fieldname_with_utype('foobaz') is None
def test_columnaliases(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.getbyucd('foo') == 23 assert record.getbyucd('bar') == 23 assert record.getbyutype('foobar') == b'Illuminatus' record.getbyucd('baz') is None record.getbyutype('foobaz') is None
def test_columnaliases(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.getbyucd('foo') == 23 assert record.getbyucd('bar') == 23 assert record.getbyutype('foobar') == b'Illuminatus' record.getbyucd('baz') is None record.getbyutype('foobaz') is None
def test_id_over_name(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults['_1'], np.ndarray) assert isinstance(dalresults['_2'], np.ndarray) table = dalresults.to_table() with pytest.raises(KeyError): assert table['_1'] with pytest.raises(KeyError): assert table['_2']
def test_id_over_name(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults['_1'], np.ndarray) assert isinstance(dalresults['_2'], np.ndarray) table = dalresults.to_table() with pytest.raises(KeyError): assert table['_1'] with pytest.raises(KeyError): assert table['_2']
def test_init(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.queryurl == 'http://example.com/query/basic' assert isinstance(dalresults.votable, VOTableFile) assert isinstance(dalresults.resultstable, VOTable) assert dalresults.fieldnames == ('1', '2') assert (dalresults.fielddescs[0].name, dalresults.fielddescs[1].name) == ('1', '2') assert dalresults.status == ('OK', 'OK')
def test_init(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.queryurl == 'http://example.com/query/basic' assert isinstance(dalresults.votable, VOTableFile) assert isinstance(dalresults.resultstable, VOTable) assert dalresults.fieldnames == ('1', '2') assert ( dalresults.fielddescs[0].name, dalresults.fielddescs[1].name ) == ('1', '2') assert dalresults.status == ('OK', 'OK')
def test_nosuchcolumn(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] with pytest.raises(KeyError): record['nosuchcolumn']
def test_nosuchcolumn(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] with pytest.raises(KeyError): record['nosuchcolumn']
def test_init_rootinfo(self): dalresults = DALResults.from_result_url( 'http://example.com/query/rootinfo') assert dalresults.status == ('OK', 'OK')
def test_len(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert len(record) == 2
def test_repr(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert repr(record) == repr((23, b'Illuminatus'))
def test_table_conversion(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults.to_table(), Table) assert len(dalresults) == len(dalresults.to_table())
def test_repr(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert repr(dalresults) == repr(dalresults.table())
def test_init_errorstatus(self): with pytest.raises(DALQueryError): DALResults.from_result_url('http://example.com/query/errorstatus')
def test_init_firstresource(self): dalresults = DALResults.from_result_url( 'http://example.com/query/firstresource') assert dalresults.status == ('OK', 'OK')
def test_init_rootinfo(self): dalresults = DALResults.from_result_url( 'http://example.com/query/rootinfo') assert dalresults.status == ('OK', 'OK')
def test_init_missingcolumns(self): with pytest.raises(DALFormatError): DALResults.from_result_url( 'http://example.com/query/missingcolumns')
def test_init_errorstatus(self): with pytest.raises(DALQueryError): DALResults.from_result_url('http://example.com/query/errorstatus')
def test_from_result_url(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.status == ('OK', 'OK')
def test_from_result_url(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert dalresults.status == ('OK', 'OK')
def test_get(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.get('2', decode=True) == 'Illuminatus'
def test_len(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert len(record) == 2
def test_table_conversion(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert isinstance(dalresults.table(), Table) assert len(dalresults) == len(dalresults.table())
def test_get(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert record.get('2', decode=True) == 'Illuminatus'
def test_repr(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] truth = b'Illuminatus' if ASTROPY_LT_4_1 else 'Illuminatus' assert repr(record) == repr((23, truth))
def test_init_missingcolumns(self): with pytest.raises(DALFormatError): DALResults.from_result_url( 'http://example.com/query/missingcolumns')
def test_repr(self): record = DALResults.from_result_url( 'http://example.com/query/basic')[0] assert repr(record) == repr((23, b'Illuminatus'))
def test_init_firstresource(self): dalresults = DALResults.from_result_url( 'http://example.com/query/firstresource') assert dalresults.status == ('OK', 'OK')
def test_repr(self): dalresults = DALResults.from_result_url( 'http://example.com/query/basic') assert repr(dalresults) == repr(dalresults.to_table())