コード例 #1
0
    def test_list_pagination(self, simple_populated_db, reset_globals_to_defaults):
        """
        Sanity check that pagination params passed correctly to wrapper func.

        (NB wrapper tested independently elsewhere).
        """
        vr.default_list_n_max = 30
        vr.default_pagesize = 5
        dbinf = simple_populated_db
        count = apiv1.count()
        assert count > vr.default_list_n_max
        ivorns = apiv1.list_ivorn()
        assert len(ivorns) == vr.default_list_n_max
        # This time we override the max:
        ivorns = apiv1.list_ivorn(n_max=0)
        assert len(ivorns) == dbinf.n_inserts
コード例 #2
0
import voeventdb.remote.apiv1 as apiv1
from astropy.coordinates import Angle, SkyCoord

# Define a search cone
cone_centre = SkyCoord(ra=149, dec=51, unit='deg')
cone_radius = Angle(3, unit='deg')

# Define a filter-set
my_filters = {
    apiv1.FilterKeys.cone: (cone_centre, cone_radius),
    apiv1.FilterKeys.ivorn_contains: 'BAT_GRB',
    apiv1.FilterKeys.role: 'observation',
}

# See how many results match our filter-set
n_results = apiv1.count(filters=my_filters)

# List all IVORNs for matching VOEvents, oldest first
matching_ivorns = apiv1.list_ivorn(
    filters=my_filters,
    order=apiv1.OrderValues.author_datetime,
)
# Fetch the raw XML for the first listed VOEvent
xml_content = apiv1.packet_xml(matching_ivorns[0])

コード例 #3
0
def test_mock_requests_empty_db(mock_requests):
    count = apiv1.count()
    assert count == 0
コード例 #4
0
def test_mock_requests_simpledb(mock_requests, simple_populated_db):
    dbinf = simple_populated_db
    count = apiv1.count()
    assert count == dbinf.n_inserts