Skip to content

Commit

Permalink
[AIRFLOW-9347] Fix QuboleHook unable to add list to tags (#9349)
Browse files Browse the repository at this point in the history
  • Loading branch information
egibbm committed Jun 24, 2020
1 parent 23faab5 commit 3190db5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
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 @@ -43,7 +43,6 @@
'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/qubole/hooks/test_qubole.py',
'tests/providers/samba/hooks/test_samba.py',
'tests/providers/yandex/hooks/test_yandex.py'
}
Expand Down

0 comments on commit 3190db5

Please sign in to comment.