class_docstr: Testing export import functionality for dashboards
class_docstr_tok: ["Testing","export","import","functionality","for","dashboards"]
code: def test_import_dashboard_2_slices(self):
      schema = get_example_default_schema()
      e_slc = self.create_slice(
          "e_slc", id=10007, table_name="energy_usage", schema=schema
      )
      b_slc = self.create_slice(
          "b_slc", id=10008, table_name="birth_names", schema=schema
      )
      dash_with_2_slices = self.create_dashboard(
          "dash_with_2_slices", slcs=[e_slc, b_slc], id=10003
      )
      dash_with_2_slices.json_metadata = json.dumps(
          {
              "remote_id": 10003,
              "expanded_slices": {
                  f"{e_slc.id}": True,
                  f"{b_slc.id}": False,
              },
              # mocked filter_scope metadata
              "filter_scopes": {
                  str(e_slc.id): {
                      "region": {
                          "scope": ["ROOT_ID"],
                          "immune": [b_slc.id],
                      }
                  }
              },
          }
      )
  
      imported_dash_id = import_dashboard(
          dash_with_2_slices, import_time=1991
      )
      imported_dash = self.get_dash(imported_dash_id)
  
      expected_dash = self.create_dashboard(
          "dash_with_2_slices", slcs=[e_slc, b_slc], id=10003
      )
      make_transient(expected_dash)
      self.assert_dash_equals(
          imported_dash,
          expected_dash,
          check_position=False,
          check_slugs=False,
      )
      i_e_slc = self.get_slice_by_name("e_slc")
      i_b_slc = self.get_slice_by_name("b_slc")
      expected_json_metadata = {
          "remote_id": 10003,
          "import_time": 1991,
          "filter_scopes": {
              str(i_e_slc.id): {
                  "region": {
                      "scope": ["ROOT_ID"],
                      "immune": [i_b_slc.id],
                  }
              }
          },
          "expanded_slices": {
              f"{i_e_slc.id}": True,
              f"{i_b_slc.id}": False,
          },
      }
      self.assertEqual(
          expected_json_metadata,
          json.loads(imported_dash.json_metadata),
      )
  
imports: import json
  import unittest
  from tests.integration_tests.fixtures.birth_names_dashboard import load_birth_names_dashboard_with_slices, load_birth_names_data
  import pytest
  from flask import g
  from sqlalchemy.orm.session import make_transient
  from tests.integration_tests.fixtures.energy_dashboard import load_energy_table_with_slice, load_energy_table_data
  from tests.integration_tests.test_app import app
  from superset.commands.dashboard.importers.v0 import decode_dashboards
  from superset import db, security_manager
  from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
  from superset.commands.dashboard.importers.v0 import import_chart, import_dashboard
  from superset.commands.dataset.importers.v0 import import_dataset
  from superset.models.dashboard import Dashboard
  from superset.models.slice import Slice
  from superset.utils.core import DatasourceType, get_example_default_schema
  from superset.utils.database import get_example_database
  from tests.integration_tests.fixtures.world_bank_dashboard import load_world_bank_dashboard_with_slices, load_world_bank_data
  from .base_tests import SupersetTestCase
label_desc: Use image node_id 19 for calling the TestImportExport obj's underlying member method code with example usage: obj.test_import_dashboard_2_slices() without return types