code: def test_treemap_migrate(app_context: SupersetApp) -> None:
      from superset.models.slice import Slice
  
      slc = Slice(
          viz_type=MigrateTreeMap.source_viz_type,
          datasource_type="table",
          params=treemap_form_data,
          query_context=f'{{"form_data": {treemap_form_data}}}',
      )
  
      MigrateTreeMap.upgrade_slice(slc)
      assert slc.viz_type == MigrateTreeMap.target_viz_type
      # verify form_data
      new_form_data = json.loads(slc.params)
      assert new_form_data["metric"] == "sum__num"
      assert new_form_data["viz_type"] == "treemap_v2"
      assert "metrics" not in new_form_data
      assert json.dumps(
          new_form_data["form_data_bak"], sort_keys=True
      ) == json.dumps(json.loads(treemap_form_data), sort_keys=True)
  
      # verify query_context
      new_query_context = json.loads(slc.query_context)
      assert new_query_context["form_data"]["viz_type"] == "treemap_v2"
  
      # downgrade
      MigrateTreeMap.downgrade_slice(slc)
      assert slc.viz_type == MigrateTreeMap.source_viz_type
      assert json.dumps(
          json.loads(slc.params), sort_keys=True
      ) == json.dumps(json.loads(treemap_form_data), sort_keys=True)
  
imports: import json
  from superset.app import SupersetApp
  from superset.migrations.shared.migrate_viz import MigrateTreeMap
label_desc: Use image node_id 1 for calling a global function with example usage: test_treemap_migrate(app_context) without return types