2022-07-27 07:47:25 +02:00
|
|
|
# Copyright 2021 Collate
|
|
|
|
# Licensed 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.
|
|
|
|
"""
|
|
|
|
Test helper functions
|
|
|
|
"""
|
2022-07-28 14:46:25 +02:00
|
|
|
from openmetadata_managed_apis.api.utils import clean_dag_id
|
2024-05-16 15:33:42 +02:00
|
|
|
from openmetadata_managed_apis.workflows.ingestion.common import clean_name_tag
|
2022-07-27 07:47:25 +02:00
|
|
|
|
|
|
|
|
2024-05-16 15:33:42 +02:00
|
|
|
def test_clean_dag_id():
|
2022-07-27 07:47:25 +02:00
|
|
|
"""
|
2024-05-16 15:33:42 +02:00
|
|
|
To make sure airflow can parse it
|
2022-07-27 07:47:25 +02:00
|
|
|
"""
|
2024-05-16 15:33:42 +02:00
|
|
|
assert clean_dag_id("hello") == "hello"
|
|
|
|
assert clean_dag_id("hello(world)") == "hello_world_"
|
|
|
|
assert clean_dag_id("hello-world") == "hello-world"
|
|
|
|
assert clean_dag_id("%%&^++hello__") == "_hello__"
|
|
|
|
|
|
|
|
|
|
|
|
def test_clean_tag():
|
|
|
|
"""We can properly tag airflow DAGs"""
|
2022-07-27 07:47:25 +02:00
|
|
|
|
2024-05-16 15:33:42 +02:00
|
|
|
assert clean_name_tag("hello") == "hello"
|
|
|
|
assert clean_name_tag("hello(world)") == "hello(world)"
|
|
|
|
assert clean_name_tag("service.pipeline") == "pipeline"
|
2024-05-17 07:31:06 +02:00
|
|
|
assert clean_name_tag(f"service.{'a' * 200}") == "a" * 90
|