Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-9347] Fix QuboleHook unable to add list to tags #9349

Merged
merged 3 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/qubole/hooks/qubole.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,4 @@ def _add_tags(tags, value):
if isinstance(value, str):
tags.add(value)
elif isinstance(value, (list, tuple)):
tags.extend(value)
tags.update(value)
40 changes: 40 additions & 0 deletions tests/providers/qubole/hooks/test_qubole.py
Original file line number Diff line number Diff line change
@@ -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

from airflow.providers.qubole.hooks.qubole import QuboleHook

add_tags = QuboleHook._add_tags


class TestQuboleHook(unittest.TestCase):
def test_add_string_to_tags(self):
tags = {'dag_id', 'task_id'}
add_tags(tags, 'string')
self.assertEqual({'dag_id', 'task_id', 'string'}, tags)

def test_add_list_to_tags(self):
tags = {'dag_id', 'task_id'}
add_tags(tags, ['value1', 'value2'])
self.assertEqual({'dag_id', 'task_id', 'value1', 'value2'}, tags)

def test_add_tuple_to_tags(self):
tags = {'dag_id', 'task_id'}
add_tags(tags, ('value1', 'value2'))
self.assertEqual({'dag_id', 'task_id', 'value1', 'value2'}, tags)
1 change: 0 additions & 1 deletion tests/test_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
'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',
msumit marked this conversation as resolved.
Show resolved Hide resolved
'tests/providers/samba/hooks/test_samba.py',
'tests/providers/yandex/hooks/test_yandex.py'
}
Expand Down