test_encoding.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. from unittest.mock import patch
  12. import taipy.core.taipy as tp
  13. from taipy.core.config import Config
  14. def test_no_special_characters():
  15. with patch("sys.argv", ["prog"]):
  16. scenario_config = Config.configure_scenario("scenario_1")
  17. scenario = tp.create_scenario(scenario_config, name="martin")
  18. assert scenario.name == "martin"
  19. scenarios = tp.get_scenarios()
  20. assert len(scenarios) == 1
  21. assert scenarios[0].name == "martin"
  22. def test_many_special_characters():
  23. with patch("sys.argv", ["prog"]):
  24. scenario_config = Config.configure_scenario("scenario_1")
  25. special_characters = (
  26. "!#$%&'()*+,-./:;<=>?@[]^_`\\{"
  27. "|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º"
  28. "»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ"
  29. "רÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñò"
  30. "óôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ"
  31. "ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪ"
  32. "īĬĭĮįİIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇ"
  33. "ňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţ"
  34. "ŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ"
  35. )
  36. scenario = tp.create_scenario(scenario_config, name=special_characters)
  37. assert scenario.name == special_characters
  38. scenarios = tp.get_scenarios()
  39. assert len(scenarios) == 1
  40. assert scenarios[0].name == special_characters