class_docstr: Implements shared logic for tests to insert charts (slices) in the DB
class_docstr_tok: ["Implements","shared","logic","for","tests","to","insert","charts","(","slices",")","in","the","DB"]
code: def insert_chart(
      self,
      slice_name: str,
      owners: list[int],
      datasource_id: int,
      created_by=None,
      datasource_type: str = "table",
      description: Optional[str] = None,
      viz_type: Optional[str] = None,
      params: Optional[str] = None,
      cache_timeout: Optional[int] = None,
      certified_by: Optional[str] = None,
      certification_details: Optional[str] = None,
  ) -> Slice:
      obj_owners = list()
      for owner in owners:
          user = db.session.query(security_manager.user_model).get(
              owner
          )
          obj_owners.append(user)
      datasource = (
          db.session.query(SqlaTable)
          .filter_by(id=datasource_id)
          .one_or_none()
      )
      slice = Slice(
          cache_timeout=cache_timeout,
          certified_by=certified_by,
          certification_details=certification_details,
          created_by=created_by,
          datasource_id=datasource.id,
          datasource_name=datasource.name,
          datasource_type=datasource.type,
          description=description,
          owners=obj_owners,
          params=params,
          slice_name=slice_name,
          viz_type=viz_type,
      )
      db.session.add(slice)
      db.session.commit()
      return slice
  
imports: from typing import Optional
  from superset import db, security_manager
  from superset.connectors.sqla.models import SqlaTable
  from superset.models.slice import Slice
label_desc: Use image node_id 1 for calling the InsertChartMixin obj's underlying member method code with example usage: obj.insert_chart(slice_name, owners, datasource_id, created_by, datasource_type, description, viz_type, params, cache_timeout, certified_by, certification_details) and returns: slice