You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ta...@apache.org on 2024/02/21 15:38:20 UTC

(airflow) branch main updated: Fix the `prepare_engine_args` tests (#37593)

This is an automated email from the ASF dual-hosted git repository.

taragolis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ec30c60365 Fix the `prepare_engine_args` tests (#37593)
ec30c60365 is described below

commit ec30c60365260e3fc37ec668e0ddd401698bb49f
Author: Dev-iL <ir...@clearstreet.io>
AuthorDate: Wed Feb 21 17:38:13 2024 +0200

    Fix the `prepare_engine_args` tests (#37593)
---
 tests/core/test_settings.py | 28 ++++++++++++++++++++++++++++
 tests/test_settings.py      | 41 -----------------------------------------
 2 files changed, 28 insertions(+), 41 deletions(-)

diff --git a/tests/core/test_settings.py b/tests/core/test_settings.py
index 696fc11c19..0cf38f5a44 100644
--- a/tests/core/test_settings.py
+++ b/tests/core/test_settings.py
@@ -236,3 +236,31 @@ def test_sqlite_relative_path(value, expectation):
     ), patch("airflow.settings.Session"), patch("airflow.settings.engine"):
         with expectation:
             settings.configure_orm()
+
+
+class TestEngineArgs:
+    @staticmethod
+    @patch("airflow.settings.conf")
+    @patch("airflow.settings.is_sqlalchemy_v1")
+    def test_encoding_present_in_v1(is_v1, mock_conf):
+        from airflow import settings
+
+        is_v1.return_value = True
+        mock_conf.getjson.return_value = {}
+
+        engine_args = settings.prepare_engine_args()
+
+        assert "encoding" in engine_args
+
+    @staticmethod
+    @patch("airflow.settings.conf")
+    @patch("airflow.settings.is_sqlalchemy_v1")
+    def test_encoding_absent_in_v2(is_v1, mock_conf):
+        from airflow import settings
+
+        is_v1.return_value = False
+        mock_conf.getjson.return_value = {}
+
+        engine_args = settings.prepare_engine_args()
+
+        assert "encoding" not in engine_args
diff --git a/tests/test_settings.py b/tests/test_settings.py
deleted file mode 100644
index 3006adf79b..0000000000
--- a/tests/test_settings.py
+++ /dev/null
@@ -1,41 +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 __future__ import annotations
-
-from unittest.mock import patch
-
-from airflow import settings
-
-
-@patch("airflow.settings.conf")
-@patch.multiple("airflow.settings", SQL_ALCHEMY_V1=True)
-def test_encoding_present(mock_conf):
-    mock_conf.getjson.return_value = {}
-
-    engine_args = settings.prepare_engine_args()
-
-    assert "encoding" in engine_args
-
-
-@patch("airflow.settings.conf")
-@patch.multiple("airflow.settings", SQL_ALCHEMY_V1=False)
-def test_encoding_absent(mock_conf):
-    mock_conf.getjson.return_value = {}
-
-    engine_args = settings.prepare_engine_args()
-
-    assert "encoding" not in engine_args