Fix a test case inside tests/models that leaves a trace in the DB
diff --git a/tests/models/test_dagbag.py b/tests/models/test_dagbag.py
index 787086cf9d642..343eb468b9f25 100644
--- a/tests/models/test_dagbag.py
+++ b/tests/models/test_dagbag.py
@@ -44,27 +44,25 @@
 from tests.test_utils import db
 from tests.test_utils.asserts import assert_queries_count
 from tests.test_utils.config import conf_vars
-from tests.test_utils.permissions import delete_dag_specific_permissions
+
+
+def db_clean_up():
+    db.clear_db_dags()
+    db.clear_db_runs()
+    db.clear_db_serialized_dags()
+    db.clear_dag_specific_permissions()
 
 
 class TestDagBag:
     @classmethod
     def setup_class(cls):
         cls.empty_dir = mkdtemp()
+        db_clean_up()
 
     @classmethod
     def teardown_class(cls):
         shutil.rmtree(cls.empty_dir)
-
-    def setup_methods(self) -> None:
-        db.clear_db_dags()
-        db.clear_db_runs()
-        db.clear_db_serialized_dags()
-
-    def teardown_method(self) -> None:
-        db.clear_db_dags()
-        db.clear_db_runs()
-        db.clear_db_serialized_dags()
+        db_clean_up()
 
     def test_get_existing_dag(self):
         """
@@ -774,6 +772,7 @@ def test_sync_to_db_syncs_dag_specific_perms_on_update(self):
         Test that dagbag.sync_to_db will sync DAG specific permissions when a DAG is
         new or updated
         """
+        db_clean_up()
         session = settings.Session()
         with freeze_time(tz.datetime(2020, 1, 5, 0, 0, 0)) as frozen_time:
             dagbag = DagBag(
@@ -807,7 +806,7 @@ def test_sync_perm_for_dag(self, mock_security_manager):
         Test that dagbag._sync_perm_for_dag will call ApplessAirflowSecurityManager.sync_perm_for_dag
         when DAG specific perm views don't exist already or the DAG has access_control set.
         """
-        delete_dag_specific_permissions()
+        db_clean_up()
         with create_session() as session:
             security_manager = ApplessAirflowSecurityManager(session)
             mock_sync_perm_for_dag = mock_security_manager.return_value.sync_perm_for_dag
@@ -879,6 +878,7 @@ def test_get_dag_with_dag_serialization(self):
 
     def test_collect_dags_from_db(self):
         """DAGs are collected from Database"""
+        db.clear_db_dags()
         example_dags_folder = airflow.example_dags.__path__[0]
         dagbag = DagBag(example_dags_folder)
 
diff --git a/tests/test_utils/db.py b/tests/test_utils/db.py
index c6559b8e1ddfe..2c0d0ae48a15e 100644
--- a/tests/test_utils/db.py
+++ b/tests/test_utils/db.py
@@ -36,8 +36,10 @@
 )
 from airflow.models.dagcode import DagCode
 from airflow.models.serialized_dag import SerializedDagModel
+from airflow.security.permissions import RESOURCE_DAG_PREFIX
 from airflow.utils.db import add_default_pool_if_not_exists, create_default_connections
 from airflow.utils.session import create_session
+from airflow.www.fab_security.sqla.models import Permission, Resource, assoc_permission_role
 
 
 def clear_db_runs():
@@ -126,3 +128,20 @@ def clear_db_task_fail():
 def clear_db_task_reschedule():
     with create_session() as session:
         session.query(TaskReschedule).delete()
+
+
+def clear_dag_specific_permissions():
+    with create_session() as session:
+        dag_resources = session.query(Resource).filter(Resource.name.like(f"{RESOURCE_DAG_PREFIX}%")).all()
+        dag_resource_ids = [d.id for d in dag_resources]
+
+        dag_permissions = session.query(Permission).filter(Permission.resource_id.in_(dag_resource_ids)).all()
+        dag_permission_ids = [d.id for d in dag_permissions]
+
+        session.query(assoc_permission_role).filter(
+            assoc_permission_role.c.permission_view_id.in_(dag_permission_ids)
+        ).delete(synchronize_session=False)
+        session.query(Permission).filter(Permission.resource_id.in_(dag_resource_ids)).delete(
+            synchronize_session=False
+        )
+        session.query(Resource).filter(Resource.id.in_(dag_resource_ids)).delete(synchronize_session=False)
diff --git a/tests/test_utils/permissions.py b/tests/test_utils/permissions.py
deleted file mode 100644
index eabc64c503313..0000000000000
--- a/tests/test_utils/permissions.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-from airflow.security.permissions import RESOURCE_DAG_PREFIX
-from airflow.utils.session import create_session
-from airflow.www.fab_security.sqla.models import Permission, Resource, assoc_permission_role
-
-
-def delete_dag_specific_permissions():
-    with create_session() as session:
-        dag_resources = session.query(Resource).filter(Resource.name.like(f"{RESOURCE_DAG_PREFIX}%")).all()
-        dag_resource_ids = [d.id for d in dag_resources]
-
-        dag_permissions = session.query(Permission).filter(Permission.resource_id.in_(dag_resource_ids)).all()
-        dag_permission_ids = [d.id for d in dag_permissions]
-
-        session.query(assoc_permission_role).filter(
-            assoc_permission_role.c.permission_view_id.in_(dag_permission_ids)
-        ).delete(synchronize_session=False)
-        session.query(Permission).filter(Permission.resource_id.in_(dag_resource_ids)).delete(
-            synchronize_session=False
-        )
-        session.query(Resource).filter(Resource.id.in_(dag_resource_ids)).delete(synchronize_session=False)

This fixes `test_sync_perm_for_dag` test case inside `test_dagbag.py` that leaves a record for a test DAG permission in the DB. 
It causes failure on another test case (tests/www/test_security.py::test_verify_public_role_has_no_permissions) in the other suite when run sequentially

To reproduce the issue within Breeze:
`pytest --disable-pytest-warnings tests/models/test_dagbag.py::TestDagBag::test_sync_perm_for_dag`
then 
`pytest --disable-pytest-warnings tests/www/test_security.py::test_verify_public_role_has_no_permissions`

Edit:
Also, moved `delete_dag_specific_permissions` to `db` module for consistency.
Fixed, `setup_method` as it wasn't executed due to misspelling. 


---
**^ Add meaningful description above**

Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
