class_docstr: Unit tests for SerializedDagModel.
class_docstr_tok: ["Unit","tests","for","SerializedDagModel","."]
docstr: DAGs can be written into database
docstr_tok: ["DAGs","can","be","written","into","database"]
code: def test_write_dag(self):
      """DAGs can be written into database"""
      example_dags = self._write_example_dags()
  
      with create_session() as session:
          for dag in example_dags.values():
              assert SDM.has_dag(dag.dag_id)
              result = (
                  session.query(SDM)
                  .filter(SDM.dag_id == dag.dag_id)
                  .one()
              )
  
              assert result.fileloc == dag.fileloc
              # Verifies JSON schema.
              SerializedDAG.validate_schema(result.data)
  
imports: from __future__ import annotations
  from unittest import mock
  import pendulum
  import pytest
  import airflow.example_dags
  from airflow.datasets import Dataset
  from airflow.models.dag import DAG
  from airflow.models.dagbag import DagBag
  from airflow.models.dagcode import DagCode
  from airflow.models.serialized_dag import SerializedDagModel
  from airflow.operators.bash import BashOperator
  from airflow.serialization.serialized_objects import SerializedDAG
  from airflow.settings import json
  from airflow.utils.hashlib_wrapper import md5
  from airflow.utils.session import create_session
  from tests.test_utils import db
  from tests.test_utils.asserts import assert_queries_count
label_desc: Use image node_id 4 for calling the TestSerializedDagModel obj's underlying member method code with example usage: obj.test_write_dag() without return types