mik-laj commented on a change in pull request #9330:
URL: https://github.com/apache/airflow/pull/9330#discussion_r444285880
##########
File path: tests/api_connexion/endpoints/test_dag_endpoint.py
##########
@@ -14,35 +14,109 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+import os
import unittest
+from datetime import datetime
import pytest
+from airflow import DAG
+from airflow.models import DagBag
+from airflow.models.serialized_dag import SerializedDagModel
+from airflow.operators.dummy_operator import DummyOperator
from airflow.www import app
+from tests.test_utils.db import clear_db_dags, clear_db_runs,
clear_db_serialized_dags
class TestDagEndpoint(unittest.TestCase):
+ dag_id = "test_dag"
+ task_id = "op1"
+
+ @staticmethod
+ def clean_db():
+ clear_db_runs()
+ clear_db_dags()
+ clear_db_serialized_dags()
+
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.app = app.create_app(testing=True) # type:ignore
+ cls.app_serialized = app.create_app(testing=True) # type:ignore
+
+ with DAG(
+ cls.dag_id, start_date=datetime(2020, 6, 15), doc_md="details"
+ ) as dag:
+ DummyOperator(task_id=cls.task_id)
+
+ cls.dag = dag # type:ignore
+
+ dag_bag = DagBag(os.devnull, include_examples=False)
+ dag_bag.dags = {dag.dag_id: dag}
+ cls.app.dag_bag = dag_bag # type:ignore
+
+ dag_bag = DagBag(os.devnull, include_examples=False,
store_serialized_dags=True)
+ cls.app_serialized.dag_bag = dag_bag # type:ignore
def setUp(self) -> None:
+ self.clean_db()
self.client = self.app.test_client() # type:ignore
+ self.client_serialized = self.app_serialized.test_client() #
type:ignore
Review comment:
Maybe just give up this base class and divide the whole into two classes?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]