Ejemplo n.º 1
0
 def get(self, query_id):
     stored_query = get_stored_query(query_id)
     if stored_query is not None:
         self.finalize(stored_query)
     else:
         not_found_message = _("The stored query with id '{0}' was not found").format(query_id)
         raise HTTPError(404,
                         log_message=not_found_message)
Ejemplo n.º 2
0
 def get(self, query_id):
     stored_query = get_stored_query(query_id)
     if stored_query is not None:
         self.finalize(stored_query)
     else:
         not_found_message = _("The stored query with id '{0}' was not found").format(query_id)
         raise HTTPError(404,
                         log_message=not_found_message)
 def test_get_stored_query(self):
     query_example = {
         "_source": {
             "sparql_template": "",
             "description": ""
         }
     }
     query_id = "my_query_id"
     with patch("brainiak.stored_query.crud.get_instance",
                return_value=query_example):
         response = crud.get_stored_query(query_id)
         self.assertEqual(response, query_example["_source"])
Ejemplo n.º 4
0
    def get(self, query_id):
        stored_query = get_stored_query(query_id)
        if stored_query is None:
            not_found_message = _("The stored query with id '{0}' was not found during execution attempt").format(query_id)
            raise HTTPError(404,
                            log_message=not_found_message)

        valid_params = PAGING_PARAMS

        with safe_params(valid_params):
            self.query_params = QueryExecutionParamDict(self)
            response = execute_query(query_id, stored_query, self.query_params)

        # return result
        return self.finalize(response)
Ejemplo n.º 5
0
    def get(self, query_id):
        stored_query = get_stored_query(query_id)
        if stored_query is None:
            not_found_message = _("The stored query with id '{0}' was not found during execution attempt").format(query_id)
            raise HTTPError(404,
                            log_message=not_found_message)

        valid_params = PAGING_PARAMS

        with safe_params(valid_params):
            self.query_params = QueryExecutionParamDict(self)
            response = execute_query(query_id, stored_query, self.query_params)

        # return result
        return self.finalize(response)
Ejemplo n.º 6
0
    def get(self, query_id):
        stored_query = get_stored_query(query_id)
        if stored_query is None:
            not_found_message = _(
                "The stored query with id '{0}' was not found during execution attempt"
            ).format(query_id)
            raise HTTPError(404, log_message=not_found_message)

        valid_params = PAGING_PARAMS

        with safe_params(valid_params):
            self.query_params = QueryExecutionParamDict(self)
            response = execute_query(query_id, stored_query, self.query_params)
            time_to_live = stored_query.get("time_to_live",
                                            None) or self.DEFAULT_TIME_TO_LIVE

        return self.finalize_with_cache(response, time_to_live)
 def test_get_stored_query_is_none(self, mocked_get_instance):
     query_id = "query_id"
     response = crud.get_stored_query(query_id)
     self.assertEqual(response, None)