class_docstr: Unit tests for DagCode.
class_docstr_tok: ["Unit","tests","for","DagCode","."]
docstr: Test that code can be retrieved from DB when you do not have access to Code file.
  Source Code should at least exist in one of DB or File.
docstr_tok: ["Test","that","code","can","be","retrieved","from","DB","when","you","do","not","have","access","to","Code","file",".","Source","Code","should","at","least","exist","in","one","of","DB","or","File","."]
code: def test_code_can_be_read_when_no_access_to_file(self):
      """
      Test that code can be retrieved from DB when you do not have access to Code file.
      Source Code should at least exist in one of DB or File.
      """
      example_dag = make_example_dags(example_dags_module).get(
          "example_bash_operator"
      )
      example_dag.sync_to_db()
  
      # Mock that there is no access to the Dag File
      with patch(
          "airflow.models.dagcode.open_maybe_zipped"
      ) as mock_open:
          mock_open.side_effect = FileNotFoundError
          dag_code = DagCode.get_code_by_fileloc(example_dag.fileloc)
  
          for test_string in [
              "example_bash_operator",
              "also_run_this",
              "run_this_last",
          ]:
              assert test_string in dag_code
  
imports: from __future__ import annotations
  from datetime import timedelta
  from unittest.mock import patch
  import pytest
  import airflow.example_dags
  from airflow.exceptions import AirflowException
  from airflow.models import DagBag
  from airflow.models.dagcode import DagCode
  from airflow.utils.file import open_maybe_zipped
  from airflow.utils.session import create_session
  from tests.test_utils.db import clear_db_dag_code
label_desc: Use image node_id 10 for calling the TestDagCode obj's underlying member method code with example usage: obj.test_code_can_be_read_when_no_access_to_file() without return types