Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

@amoghrajesh amoghrajesh commented Jun 24, 2025

While working on https://github.com/apache/airflow/pull/52129/files, i saw this pattern in many places.

Pattern of this type:

    @provide_session
    def setup_method(self, method, session=None):
        conn = session.query(Connection).filter(Connection.conn_id == DEFAULT_CONN_ID).first()
        conn.host = HOST
        conn.schema = None
        conn.port = None
        conn.login = None
        conn.password = None
        conn.extra = json.dumps({"token": TOKEN, "host": HOST})

        session.commit()

        self.hook = DatabricksHook()

We should not be overriding default connections this way at ALL, it will make migration of providers to use task sdk extremely hard / annoying. Cleaning up that pattern to use the fixture introduced in #51930

I am introducing a way for tests to only use connections from env via #52129, which will follow this one


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@amoghrajesh amoghrajesh self-assigned this Jun 24, 2025
@amoghrajesh amoghrajesh merged commit 887ac6b into apache:main Jun 24, 2025
76 checks passed
@amoghrajesh amoghrajesh deleted the clean-up-messy-setup-methods branch June 24, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants