This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 3235670 Add unit tests for OracleOperator (#9469)
3235670 is described below
commit 3235670b058681c896ac107e13b5218e9ca930c7
Author: chipmyersjr <[email protected]>
AuthorDate: Mon Jun 22 00:34:34 2020 -0700
Add unit tests for OracleOperator (#9469)
---
tests/providers/oracle/operators/__init__.py | 16 ++++++++++
tests/providers/oracle/operators/test_oracle.py | 40 +++++++++++++++++++++++++
tests/test_project_structure.py | 1 -
3 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/tests/providers/oracle/operators/__init__.py
b/tests/providers/oracle/operators/__init__.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/tests/providers/oracle/operators/__init__.py
@@ -0,0 +1,16 @@
+# 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.
diff --git a/tests/providers/oracle/operators/test_oracle.py
b/tests/providers/oracle/operators/test_oracle.py
new file mode 100644
index 0000000..729cced
--- /dev/null
+++ b/tests/providers/oracle/operators/test_oracle.py
@@ -0,0 +1,40 @@
+# 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 unittest
+
+import mock
+
+from airflow.providers.oracle.hooks.oracle import OracleHook
+from airflow.providers.oracle.operators.oracle import OracleOperator
+
+
+class TestOracleOperator(unittest.TestCase):
+ @mock.patch.object(OracleHook, 'run')
+ def test_execute(self, mock_run):
+ sql = 'SELECT * FROM test_table'
+ oracle_conn_id = 'oracle_default'
+ parameters = {'parameter': 'value'}
+ autocommit = False
+ context = "test_context"
+ task_id = "test_task_id"
+
+ operator = OracleOperator(sql=sql, oracle_conn_id=oracle_conn_id,
parameters=parameters,
+ autocommit=autocommit, task_id=task_id)
+ operator.execute(context=context)
+
+ mock_run.assert_called_once_with(sql, autocommit=autocommit,
parameters=parameters)
diff --git a/tests/test_project_structure.py b/tests/test_project_structure.py
index fa693ff..b30fd1a 100644
--- a/tests/test_project_structure.py
+++ b/tests/test_project_structure.py
@@ -43,7 +43,6 @@ MISSING_TEST_FILES = {
'tests/providers/jenkins/hooks/test_jenkins.py',
'tests/providers/microsoft/azure/sensors/test_azure_cosmos.py',
'tests/providers/microsoft/mssql/hooks/test_mssql.py',
- 'tests/providers/oracle/operators/test_oracle.py',
'tests/providers/qubole/hooks/test_qubole.py',
'tests/providers/samba/hooks/test_samba.py',
'tests/providers/yandex/hooks/test_yandex.py'