2020-04-23 07:30:48 -04:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2023-06-01 15:01:10 -04:00
|
|
|
from typing import Any, Optional
|
2020-04-23 07:30:48 -04:00
|
|
|
|
2021-11-18 12:53:56 -05:00
|
|
|
from tests.common.query_context_generator import QueryContextGenerator
|
2021-08-02 15:45:55 -04:00
|
|
|
from tests.integration_tests.base_tests import SupersetTestCase
|
2020-12-04 07:40:31 -05:00
|
|
|
|
2020-12-22 20:10:19 -05:00
|
|
|
|
2021-11-18 12:53:56 -05:00
|
|
|
class QueryContextGeneratorInteg(QueryContextGenerator):
|
2021-12-03 06:42:28 -05:00
|
|
|
def get_table(self, name, id_, type_):
|
2021-11-18 12:53:56 -05:00
|
|
|
return SupersetTestCase.get_table(name=name)
|
2020-04-23 07:30:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
def get_query_context(
|
2021-07-28 10:34:39 -04:00
|
|
|
query_name: str,
|
|
|
|
add_postprocessing_operations: bool = False,
|
|
|
|
add_time_offsets: bool = False,
|
2023-06-01 15:01:10 -04:00
|
|
|
form_data: Optional[dict[str, Any]] = None,
|
|
|
|
) -> dict[str, Any]:
|
2020-04-23 07:30:48 -04:00
|
|
|
"""
|
|
|
|
Create a request payload for retrieving a QueryContext object via the
|
|
|
|
`api/v1/chart/data` endpoint. By default returns a payload corresponding to one
|
|
|
|
generated by the "Boy Name Cloud" chart in the examples.
|
2020-12-22 20:10:19 -05:00
|
|
|
:param query_name: name of an example query, which is always in the format
|
|
|
|
of `datasource_name[:test_case_name]`, where `:test_case_name` is optional.
|
2020-04-23 07:30:48 -04:00
|
|
|
:param add_postprocessing_operations: Add post-processing operations to QueryObject
|
2021-07-28 10:34:39 -04:00
|
|
|
:param add_time_offsets: Add time offsets to QueryObject(advanced analytics)
|
2021-12-03 06:42:28 -05:00
|
|
|
:param form_data: chart metadata
|
2020-04-23 07:30:48 -04:00
|
|
|
:return: Request payload
|
|
|
|
"""
|
2021-11-18 12:53:56 -05:00
|
|
|
return QueryContextGeneratorInteg().generate(
|
2021-12-03 06:42:28 -05:00
|
|
|
query_name=query_name,
|
|
|
|
add_postprocessing_operations=add_postprocessing_operations,
|
|
|
|
add_time_offsets=add_time_offsets,
|
|
|
|
form_data=form_data,
|
2021-11-18 12:53:56 -05:00
|
|
|
)
|