class_docstr: Unit tests for SerializedDagModel.
class_docstr_tok: ["Unit","tests","for","SerializedDagModel","."]
docstr: Test Serialized DAG is updated if DAG is changed
docstr_tok: ["Test","Serialized","DAG","is","updated","if","DAG","is","changed"]
code: def test_serialized_dag_is_updated_if_dag_is_changed(self):
      """Test Serialized DAG is updated if DAG is changed"""
      example_dags = make_example_dags(example_dags_module)
      example_bash_op_dag = example_dags.get("example_bash_operator")
      dag_updated = SDM.write_dag(dag=example_bash_op_dag)
      assert dag_updated is True
  
      with create_session() as session:
          s_dag = session.get(SDM, example_bash_op_dag.dag_id)
  
          # Test that if DAG is not changed, Serialized DAG is not re-written and last_updated
          # column is not updated
          dag_updated = SDM.write_dag(dag=example_bash_op_dag)
          s_dag_1 = session.get(SDM, example_bash_op_dag.dag_id)
  
          assert s_dag_1.dag_hash == s_dag.dag_hash
          assert s_dag.last_updated == s_dag_1.last_updated
          assert dag_updated is False
  
          # Update DAG
          example_bash_op_dag.tags += ["new_tag"]
          assert set(example_bash_op_dag.tags) == {
              "example",
              "example2",
              "new_tag",
          }
  
          dag_updated = SDM.write_dag(dag=example_bash_op_dag)
          s_dag_2 = session.get(SDM, example_bash_op_dag.dag_id)
  
          assert s_dag.last_updated != s_dag_2.last_updated
          assert s_dag.dag_hash != s_dag_2.dag_hash
          assert s_dag_2.data["dag"]["tags"] == [
              "example",
              "example2",
              "new_tag",
          ]
          assert dag_updated is True
  
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 5 for calling the TestSerializedDagModel obj's underlying member method code with example usage: obj.test_serialized_dag_is_updated_if_dag_is_changed() without return types