You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/02 00:46:31 UTC
[GitHub] [airflow] jhtimmins commented on a change in pull request #15141: Share app instance between Kerberos tests
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")
-@pytest.mark.integration("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(
+@pytest.fixture(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)
+
+
+@pytest.fixture(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")
-@pytest.mark.integration("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(
+@pytest.fixture(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)
+
+
+@pytest.fixture(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()
+
+@pytest.mark.integration("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:
users@infra.apache.org