test_expandable.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 taipy.gui import Gui
  12. def test_expandable_md_1(gui: Gui, helpers):
  13. md_string = """
  14. <|Expandable section|expandable|not expanded|
  15. # This is an expandable section
  16. |>
  17. """
  18. expected_list = [
  19. "<Expandable",
  20. "expanded={false}",
  21. 'title="Expandable section"',
  22. "<h1",
  23. "This is an expandable section",
  24. ]
  25. helpers.test_control_md(gui, md_string, expected_list)
  26. def test_expandable_md_2(gui: Gui, helpers):
  27. md_string = """
  28. <|expandable.start|title=Expandable section|not expanded|>
  29. # This is an expandable section
  30. <|expandable.end|>
  31. """
  32. expected_list = [
  33. "<Expandable",
  34. "expanded={false}",
  35. 'title="Expandable section"',
  36. "<h1",
  37. "This is an expandable section",
  38. ]
  39. helpers.test_control_md(gui, md_string, expected_list)
  40. def test_expandable_html(gui: Gui, helpers):
  41. html_string = '<taipy:expandable title="Expandable section" expanded="false"><h1>This is an expandable section</h1></taipy:expandable >' # noqa: E501
  42. expected_list = [
  43. "<Expandable",
  44. "expanded={false}",
  45. 'title="Expandable section"',
  46. "<h1",
  47. "This is an expandable section",
  48. ]
  49. helpers.test_control_html(gui, html_string, expected_list)