1
0

test_md_parsing.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright 2021-2025 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 taipy.gui import Gui
  12. def test_invalid_control_name(gui: Gui, helpers):
  13. md_string = "<|invalid|invalid|>"
  14. expected_list = ["UNKNOWN ELEMENT TYPE 'invalid'"]
  15. helpers.test_control_md(gui, md_string, expected_list)
  16. def test_value_to_negated_property(gui: Gui, helpers):
  17. md_string = "<|button|not active=true|>"
  18. expected_list = ["<Button", "active={false}"]
  19. helpers.test_control_md(gui, md_string, expected_list)
  20. def test_invalid_property_value(gui: Gui, helpers):
  21. md_string = "<|button|let's try that!|>"
  22. expected_list = ["<Button", 'label="&lt;Empty&gt;"']
  23. helpers.test_control_md(gui, md_string, expected_list)
  24. def test_unclosed_block(gui: Gui, helpers):
  25. md_string = "<|"
  26. expected_list = ["<Part", "/>"]
  27. helpers.test_control_md(gui, md_string, expected_list)
  28. def test_opening_unknown_block(gui: Gui, helpers):
  29. md_string = "<|unknown"
  30. expected_list = ["<Part", 'className="unknown"']
  31. helpers.test_control_md(gui, md_string, expected_list)
  32. def test_closing_unknown_block(gui: Gui, helpers):
  33. md_string = "|>"
  34. expected_list = ["<div>", "No matching opened tag", "</div>"]
  35. helpers.test_control_md(gui, md_string, expected_list)
  36. def test_md_link(gui: Gui, helpers):
  37. md_string = "[content](link)"
  38. expected_list = ["<a", 'href="link"', "content</a>"]
  39. helpers.test_control_md(gui, md_string, expected_list)
  40. def test_html_in_md(gui: Gui, helpers):
  41. md_string = "<center> <|Hello|text|> </center>"
  42. expected_list = ["<center>", "<div", "Hello", "</div>", "</center>"]
  43. helpers.test_control_md(gui, md_string, expected_list)