docstr: Ensure that time_offsets can generate the correct query
docstr_tok: ["Ensure","that","time_offsets","can","generate","the","correct","query"]
code: def test_time_offsets_in_query_object(self):
      """
      Ensure that time_offsets can generate the correct query
      """
      self.login(username="admin")
      payload = get_query_context("birth_names")
      payload["queries"][0]["metrics"] = ["sum__num"]
      payload["queries"][0]["groupby"] = ["name"]
      payload["queries"][0]["is_timeseries"] = True
      payload["queries"][0]["timeseries_limit"] = 5
      payload["queries"][0]["time_offsets"] = [
          "1 year ago",
          "1 year later",
      ]
      payload["queries"][0]["time_range"] = "1990 : 1991"
      query_context = ChartDataQueryContextSchema().load(payload)
      responses = query_context.get_payload()
      self.assertEqual(
          responses["queries"][0]["colnames"],
          [
              "__timestamp",
              "name",
              "sum__num",
              "sum__num__1 year ago",
              "sum__num__1 year later",
          ],
      )
  
      sqls = [
          sql
          for sql in responses["queries"][0]["query"].split(";")
          if sql.strip()
      ]
      self.assertEqual(len(sqls), 3)
      # 1 year ago
      assert re.search(r"1989-01-01.+1990-01-01", sqls[1], re.S)
      assert re.search(r"1990-01-01.+1991-01-01", sqls[1], re.S)
  
      # # 1 year later
      assert re.search(r"1991-01-01.+1992-01-01", sqls[2], re.S)
      assert re.search(r"1990-01-01.+1991-01-01", sqls[2], re.S)
  
imports: import re
  import time
  from typing import Any
  import numpy
  import pandas
  import pytest
  from pandas import DateOffset
  from superset import db
  from superset.charts.schemas import ChartDataQueryContextSchema
  from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
  from superset.common.query_context import QueryContext
  from superset.common.query_context_factory import QueryContextFactory
  from superset.common.query_object import QueryObject
  from superset.connectors.sqla.models import SqlMetric
  from superset.daos.datasource import DatasourceDAO
  from superset.extensions import cache_manager
  from superset.superset_typing import AdhocColumn
  from superset.utils.core import AdhocMetricExpressionType, backend, DatasourceType, QueryStatus
  from superset.utils.pandas_postprocessing.utils import FLAT_COLUMN_SEPARATOR
  from tests.integration_tests.base_tests import SupersetTestCase
  from tests.integration_tests.conftest import only_postgresql, only_sqlite
  from tests.integration_tests.fixtures.birth_names_dashboard import load_birth_names_dashboard_with_slices, load_birth_names_data
  from tests.integration_tests.fixtures.query_context import get_query_context
label_desc: Use image node_id 19 for calling the TestQueryContext obj's underlying member method code with example usage: obj.test_time_offsets_in_query_object() without return types