docstr: Ensure that the deserialized QueryContext contains all required fields.
docstr_tok: ["Ensure","that","the","deserialized","QueryContext","contains","all","required","fields","."]
code: def test_schema_deserialization(self):
      """
      Ensure that the deserialized QueryContext contains all required fields.
      """
  
      payload = get_query_context(
          "birth_names", add_postprocessing_operations=True
      )
      query_context = ChartDataQueryContextSchema().load(payload)
      self.assertEqual(
          len(query_context.queries), len(payload["queries"])
      )
  
      for query_idx, query in enumerate(query_context.queries):
          payload_query = payload["queries"][query_idx]
  
          # check basic properties
          self.assertEqual(query.extras, payload_query["extras"])
          self.assertEqual(query.filter, payload_query["filters"])
          self.assertEqual(query.columns, payload_query["columns"])
  
          # metrics are mutated during creation
          for metric_idx, metric in enumerate(query.metrics):
              payload_metric = payload_query["metrics"][metric_idx]
              payload_metric = (
                  payload_metric
                  if "expressionType" in payload_metric
                  else payload_metric["label"]
              )
              self.assertEqual(metric, payload_metric)
  
          self.assertEqual(query.orderby, payload_query["orderby"])
          self.assertEqual(
              query.time_range, payload_query["time_range"]
          )
  
          # check post processing operation properties
          for post_proc_idx, post_proc in enumerate(
              query.post_processing
          ):
              payload_post_proc = payload_query["post_processing"][
                  post_proc_idx
              ]
              self.assertEqual(
                  post_proc["operation"], payload_post_proc["operation"]
              )
              self.assertEqual(
                  post_proc["options"], payload_post_proc["options"]
              )
  
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 1 for calling the TestQueryContext obj's underlying member method code with example usage: obj.test_schema_deserialization() without return types