jhtimmins commented on a change in pull request #15141:
URL: https://github.com/apache/airflow/pull/15141#discussion_r606018061
##########
File path: tests/api/auth/backend/test_kerberos_auth.py
##########
@@ -19,42 +19,46 @@
import json
import os
import socket
-import unittest
from datetime import datetime
from unittest import mock
import pytest
from airflow.api.auth.backend.kerberos_auth import CLIENT_AUTH
from airflow.models import DagBag
-from airflow.www import app as application
+from airflow.www import app
from tests.test_utils.config import conf_vars
from tests.test_utils.db import clear_db_dags
KRB5_KTNAME = os.environ.get("KRB5_KTNAME")
[email protected]("kerberos")
-class TestApiKerberos(unittest.TestCase):
- @classmethod
- def setUpClass(cls):
- dagbag = DagBag(include_examples=True)
- for dag in dagbag.dags.values():
- dag.sync_to_db()
-
- @conf_vars(
[email protected](scope="module")
+def app_for_kerberos():
+ with conf_vars(
{
("api", "auth_backend"): "airflow.api.auth.backend.kerberos_auth",
("kerberos", "keytab"): KRB5_KTNAME,
('api', 'enable_experimental_api'): 'true',
}
- )
- def setUp(self):
- self.app = application.create_app(testing=True)
+ ):
+ yield app.create_app(testing=True)
+
+
[email protected](scope="module", autouse=True)
+def dagbag_to_db():
Review comment:
It doesn't look like `dagbag_to_db` is getting used; does it have a
purpose that's just not clear to me?
##########
File path: tests/api/auth/backend/test_kerberos_auth.py
##########
@@ -19,42 +19,46 @@
import json
import os
import socket
-import unittest
from datetime import datetime
from unittest import mock
import pytest
from airflow.api.auth.backend.kerberos_auth import CLIENT_AUTH
from airflow.models import DagBag
-from airflow.www import app as application
+from airflow.www import app
from tests.test_utils.config import conf_vars
from tests.test_utils.db import clear_db_dags
KRB5_KTNAME = os.environ.get("KRB5_KTNAME")
[email protected]("kerberos")
-class TestApiKerberos(unittest.TestCase):
- @classmethod
- def setUpClass(cls):
- dagbag = DagBag(include_examples=True)
- for dag in dagbag.dags.values():
- dag.sync_to_db()
-
- @conf_vars(
[email protected](scope="module")
+def app_for_kerberos():
+ with conf_vars(
{
("api", "auth_backend"): "airflow.api.auth.backend.kerberos_auth",
("kerberos", "keytab"): KRB5_KTNAME,
('api', 'enable_experimental_api'): 'true',
}
- )
- def setUp(self):
- self.app = application.create_app(testing=True)
+ ):
+ yield app.create_app(testing=True)
+
+
[email protected](scope="module", autouse=True)
+def dagbag_to_db():
+ dagbag = DagBag(include_examples=True)
+ for dag in dagbag.dags.values():
+ dag.sync_to_db()
+ yield
+ clear_db_dags()
- @classmethod
- def tearDownClass(cls) -> None:
- clear_db_dags()
+
[email protected]("kerberos")
+class TestApiKerberos:
+ @pytest.fixture(autouse=True)
+ def _set_attrs(self, app_for_kerberos):
Review comment:
I'm not familiar with `_set_attrs`, where is this from?
--
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]