mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix: slug is empty if filename is non-ASCII (#22118)
This commit is contained in:
44
tests/unit_tests/utils/test_file.py
Normal file
44
tests/unit_tests/utils/test_file.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 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 pytest
|
||||
|
||||
from superset.utils.file import get_filename
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_name,model_id,skip_id,expected_filename",
|
||||
[
|
||||
("Energy Sankey", 132, False, "Energy_Sankey_132"),
|
||||
("Energy Sankey", 132, True, "Energy_Sankey"),
|
||||
("folder1/Energy Sankey", 132, True, "folder1_Energy_Sankey"),
|
||||
("D:\\Charts\\Energy Sankey", 132, True, "DChartsEnergy_Sankey"),
|
||||
("🥴🥴🥴", 4751, False, "4751"),
|
||||
("🥴🥴🥴", 4751, True, "4751"),
|
||||
("Energy Sankey 🥴🥴🥴", 4751, False, "Energy_Sankey_4751"),
|
||||
("Energy Sankey 🥴🥴🥴", 4751, True, "Energy_Sankey"),
|
||||
("你好", 475, False, "475"),
|
||||
("你好", 475, True, "475"),
|
||||
("Energy Sankey 你好", 475, False, "Energy_Sankey_475"),
|
||||
("Energy Sankey 你好", 475, True, "Energy_Sankey"),
|
||||
],
|
||||
)
|
||||
def test_get_filename(
|
||||
model_name: str, model_id: int, skip_id: bool, expected_filename: str
|
||||
) -> None:
|
||||
original_filename = get_filename(model_name, model_id, skip_id)
|
||||
assert expected_filename == original_filename
|
||||
Reference in New Issue
Block a user