def test_query_object(self):
        connHandler = DummyConnHandler()
        tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
        tap = GaiaClass(connHandler, tapplus)
        # Launch response: we use default response because the query contains
        # decimals
        responseLaunchJob = DummyResponse()
        responseLaunchJob.set_status_code(200)
        responseLaunchJob.set_message("OK")
        jobDataFile = data_path('job_1.vot')
        jobData = utils.read_file_content(jobDataFile)
        responseLaunchJob.set_data(method='POST',
                                   context=None,
                                   body=jobData,
                                   headers=None)
        # The query contains decimals: force default response
        connHandler.set_default_response(responseLaunchJob)
        sc = SkyCoord(ra=29.0,
                      dec=15.0,
                      unit=(u.degree, u.degree),
                      frame='icrs')
        with pytest.raises(ValueError) as err:
            tap.query_object(sc)
        assert "Missing required argument: 'width'" in err.value.args[0]

        width = Quantity(12, u.deg)

        with pytest.raises(ValueError) as err:
            tap.query_object(sc, width=width)
        assert "Missing required argument: 'height'" in err.value.args[0]

        height = Quantity(10, u.deg)
        table = tap.query_object(sc, width=width, height=height)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table, 'alpha', 'alpha', None, np.float64)
        self.__check_results_column(table, 'delta', 'delta', None, np.float64)
        self.__check_results_column(table, 'source_id', 'source_id', None,
                                    np.object)
        self.__check_results_column(table, 'table1_oid', 'table1_oid', None,
                                    np.int32)
        # by radius
        radius = Quantity(1, u.deg)
        table = tap.query_object(sc, radius=radius)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table, 'alpha', 'alpha', None, np.float64)
        self.__check_results_column(table, 'delta', 'delta', None, np.float64)
        self.__check_results_column(table, 'source_id', 'source_id', None,
                                    np.object)
        self.__check_results_column(table, 'table1_oid', 'table1_oid', None,
                                    np.int32)
Пример #2
0
    def test_query_object(self):
        connHandler = DummyConnHandler()
        tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
        tap = GaiaClass(tapplus)
        # Launch response: we use default response because the query contains decimals
        responseLaunchJob = DummyResponse()
        responseLaunchJob.set_status_code(200)
        responseLaunchJob.set_message("OK")
        jobDataFile = data_path('job_1.vot')
        jobData = utils.read_file_content(jobDataFile)
        responseLaunchJob.set_data(method='POST',
                                   context=None,
                                   body=jobData,
                                   headers=None)
        # The query contains decimals: force default response
        connHandler.set_default_response(responseLaunchJob)
        sc = SkyCoord(ra=29.0, dec=15.0, unit=(u.degree, u.degree), frame='icrs')
        with pytest.raises(ValueError) as err:
            tap.query_object(sc)
        assert "Missing required argument: 'width'" in err.value.args[0]

        width = Quantity(12, u.deg)

        with pytest.raises(ValueError) as err:
            tap.query_object(sc, width=width)
        assert "Missing required argument: 'height'" in err.value.args[0]

        height = Quantity(10, u.deg)
        table = tap.query_object(sc, width=width, height=height)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table,
                                    'alpha',
                                    'alpha',
                                    None,
                                    np.float64)
        self.__check_results_column(table,
                                    'delta',
                                    'delta',
                                    None,
                                    np.float64)
        self.__check_results_column(table,
                                    'source_id',
                                    'source_id',
                                    None,
                                    np.object)
        self.__check_results_column(table,
                                    'table1_oid',
                                    'table1_oid',
                                    None,
                                    np.int32)
        # by radius
        radius = Quantity(1, u.deg)
        table = tap.query_object(sc, radius=radius)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table,
                                    'alpha',
                                    'alpha',
                                    None,
                                    np.float64)
        self.__check_results_column(table,
                                    'delta',
                                    'delta',
                                    None,
                                    np.float64)
        self.__check_results_column(table,
                                    'source_id',
                                    'source_id',
                                    None,
                                    np.object)
        self.__check_results_column(table,
                                    'table1_oid',
                                    'table1_oid',
                                    None,
                                    np.int32)
Пример #3
0
    def test_query_object(self):
        conn_handler = DummyConnHandler()
        # Launch response: we use default response because the query contains
        # decimals
        dummy_response = DummyResponse()
        dummy_response.set_status_code(200)
        dummy_response.set_message("OK")

        message_text = "1653401204784D[type: -100,-1]=Gaia dev is under maintenance"

        dummy_response.set_data(method='GET',
                                context=None,
                                body=message_text,
                                headers=None)
        conn_handler.set_default_response(dummy_response)

        # show_server_messages
        tableRequest = 'notification?action=GetNotifications'
        conn_handler.set_response(tableRequest, dummy_response)

        tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
        tap = GaiaClass(conn_handler, tapplus, show_server_messages=True)
        # Launch response: we use default response because the query contains
        # decimals
        response_launch_job = DummyResponse()
        response_launch_job.set_status_code(200)
        response_launch_job.set_message("OK")
        job_data_file = data_path('job_1.vot')
        job_data = utils.read_file_content(job_data_file)
        response_launch_job.set_data(method='POST',
                                     context=None,
                                     body=job_data,
                                     headers=None)
        # The query contains decimals: force default response
        conn_handler.set_default_response(response_launch_job)
        sc = SkyCoord(ra=29.0,
                      dec=15.0,
                      unit=(u.degree, u.degree),
                      frame='icrs')
        with pytest.raises(ValueError) as err:
            tap.query_object(sc)
        assert "Missing required argument: width" in err.value.args[0]

        width = Quantity(12, u.deg)

        with pytest.raises(ValueError) as err:
            tap.query_object(sc, width=width)
        assert "Missing required argument: height" in err.value.args[0]

        height = Quantity(10, u.deg)
        table = tap.query_object(sc, width=width, height=height)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table, 'alpha', 'alpha', None, np.float64)
        self.__check_results_column(table, 'delta', 'delta', None, np.float64)
        self.__check_results_column(table, 'source_id', 'source_id', None,
                                    object)
        self.__check_results_column(table, 'table1_oid', 'table1_oid', None,
                                    np.int32)
        # by radius
        radius = Quantity(1, u.deg)
        table = tap.query_object(sc, radius=radius)
        assert len(table) == 3, \
            "Wrong job results (num rows). Expected: %d, found %d" % \
            (3, len(table))
        self.__check_results_column(table, 'alpha', 'alpha', None, np.float64)
        self.__check_results_column(table, 'delta', 'delta', None, np.float64)
        self.__check_results_column(table, 'source_id', 'source_id', None,
                                    object)
        self.__check_results_column(table, 'table1_oid', 'table1_oid', None,
                                    np.int32)