You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by di...@apache.org on 2020/06/20 03:02:45 UTC
[airflow] 03/04: remove core_to_contrib
This is an automated email from the ASF dual-hosted git repository.
dimberman pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit db795a4e43778dd2f18ccfa3ab054e9a2ad823f9
Author: Daniel Imberman <da...@astronomer.io>
AuthorDate: Fri Jun 19 19:35:47 2020 -0700
remove core_to_contrib
---
airflow/operators/sql.py | 16 +++---
tests/test_core_to_contrib.py | 129 ------------------------------------------
2 files changed, 8 insertions(+), 137 deletions(-)
diff --git a/airflow/operators/sql.py b/airflow/operators/sql.py
index 83cb201..91ddc1a 100644
--- a/airflow/operators/sql.py
+++ b/airflow/operators/sql.py
@@ -154,14 +154,14 @@ class SQLValueCheckOperator(BaseOperator):
@apply_defaults
def __init__(
- self,
- sql,
- pass_value,
- tolerance=None,
- conn_id=None,
- *args,
- **kwargs
- ):
+ self,
+ sql,
+ pass_value,
+ tolerance=None,
+ conn_id=None,
+ *args,
+ **kwargs
+ ):
super(SQLValueCheckOperator, self).__init__(*args, **kwargs)
self.sql = sql
self.conn_id = conn_id
diff --git a/tests/test_core_to_contrib.py b/tests/test_core_to_contrib.py
deleted file mode 100644
index 127905a..0000000
--- a/tests/test_core_to_contrib.py
+++ /dev/null
@@ -1,129 +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.
-
-import importlib
-import sys
-from inspect import isabstract
-from unittest import TestCase, mock
-
-from parameterized import parameterized
-
-
-OPERATORS = [
- (
- 'airflow.operators.check_operator.CheckOperator',
- 'airflow.operators.sql.SQLCheckOperator',
- ),
- (
- 'airflow.operators.check_operator.IntervalCheckOperator',
- 'airflow.operators.sql.SQLIntervalCheckOperator',
- ),
- (
- 'airflow.operators.check_operator.ValueCheckOperator',
- 'airflow.operators.sql.SQLValueCheckOperator',
- ),
- (
- 'airflow.operators.check_operator.ThresholdCheckOperator',
- 'airflow.operators.sql.SQLThresholdCheckOperator',
- ),
- (
- 'airflow.operators.sql_branch_operator.BranchSqlOperator',
- 'airflow.operators.sql.BranchSQLOperator',
- ),
-]
-
-
-ALL = OPERATORS
-
-RENAMED_HOOKS = [
- (old_class, new_class)
- for old_class, new_class in OPERATORS
- if old_class.rpartition(".")[2] != new_class.rpartition(".")[2]
-]
-
-
-class TestMovingCoreToContrib(TestCase):
- @staticmethod
- def assert_warning(msg, warning):
- error = "Text '{}' not in warnings".format(msg)
- assert any(msg in str(w) for w in warning.warnings), error
-
- def assert_is_subclass(self, clazz, other):
- self.assertTrue(
- issubclass(clazz, other), "{} is not subclass of {}".format(clazz, other)
- )
-
- def assert_proper_import(self, old_resource, new_resource):
- new_path, _, _ = new_resource.rpartition(".")
- old_path, _, _ = old_resource.rpartition(".")
- with self.assertWarns(DeprecationWarning) as warning_msg:
- # Reload to see deprecation warning each time
- importlib.reload(importlib.import_module(old_path))
- self.assert_warning(new_path, warning_msg)
-
- def skip_test_with_mssql_in_py38(self, path_a="", path_b=""):
- py_38 = sys.version_info >= (3, 8)
- if py_38:
- if "mssql" in path_a or "mssql" in path_b:
- raise self.skipTest("Mssql package not avaible when Python >= 3.8.")
-
- @staticmethod
- def get_class_from_path(path_to_class, parent=False):
- """
- :param parent indicates if "path_to_class" arg is super class
- """
-
- path, _, class_name = path_to_class.rpartition(".")
- module = importlib.import_module(path)
- class_ = getattr(module, class_name)
-
- if isabstract(class_) and not parent:
- class_name = "Mock({class_name})".format(class_name=class_.__name__)
-
- attributes = {
- a: mock.MagicMock() for a in class_.__abstractmethods__
- }
-
- new_class = type(class_name, (class_,), attributes)
- return new_class
- return class_
-
- @parameterized.expand(RENAMED_HOOKS)
- def test_is_class_deprecated(self, new_module, old_module):
- self.skip_test_with_mssql_in_py38(new_module, old_module)
- deprecation_warning_msg = "This class is deprecated."
- old_module_class = self.get_class_from_path(old_module)
- with self.assertWarnsRegex(DeprecationWarning, deprecation_warning_msg) as wrn:
- with mock.patch("{}.__init__".format(new_module)) as init_mock:
- init_mock.return_value = None
- self.assertTrue(deprecation_warning_msg, wrn)
- old_module_class()
- init_mock.assert_called_once_with()
-
- @parameterized.expand(ALL)
- def test_is_subclass(self, parent_class_path, sub_class_path):
- self.skip_test_with_mssql_in_py38(parent_class_path, sub_class_path)
- with mock.patch("{}.__init__".format(parent_class_path)):
- parent_class_path = self.get_class_from_path(parent_class_path, parent=True)
- sub_class_path = self.get_class_from_path(sub_class_path)
- self.assert_is_subclass(sub_class_path, parent_class_path)
-
- @parameterized.expand(ALL)
- def test_warning_on_import(self, new_path, old_path):
- self.skip_test_with_mssql_in_py38(new_path, old_path)
- self.assert_proper_import(old_path, new_path)