test_pane.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2023 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_pane_md(gui: Gui, test_client, helpers):
  13. gui._bind_var_val("show_pane", False)
  14. md_string = """
  15. <|{show_pane}|pane|not persistent|
  16. # This is a Pane
  17. |>
  18. """
  19. expected_list = [
  20. "<Pane",
  21. 'anchor="left"',
  22. 'updateVarName="_TpB_tpec_TpExPr_show_pane_TPMDL_0"',
  23. "open={_TpB_tpec_TpExPr_show_pane_TPMDL_0}",
  24. "<h1",
  25. "This is a Pane</h1></Pane>",
  26. ]
  27. helpers.test_control_md(gui, md_string, expected_list)
  28. def test_pane_persistent_md(gui: Gui, test_client, helpers):
  29. gui._bind_var_val("show_pane", False)
  30. md_string = """
  31. <|{show_pane}|pane|persistent|
  32. # This is a Pane
  33. |>
  34. """
  35. expected_list = [
  36. "<Pane",
  37. 'anchor="left"',
  38. "persistent={true}",
  39. 'updateVarName="_TpB_tpec_TpExPr_show_pane_TPMDL_0"',
  40. "open={_TpB_tpec_TpExPr_show_pane_TPMDL_0}",
  41. "<h1",
  42. "This is a Pane</h1></Pane>",
  43. ]
  44. helpers.test_control_md(gui, md_string, expected_list)
  45. def test_pane_html(gui: Gui, test_client, helpers):
  46. gui._bind_var_val("show_pane", False)
  47. html_string = '<taipy:pane open="{show_pane}" persistent="false"><h1>This is a Pane</h1></taipy:pane>'
  48. expected_list = [
  49. "<Pane",
  50. 'anchor="left"',
  51. 'updateVarName="_TpB_tpec_TpExPr_show_pane_TPMDL_0"',
  52. "open={_TpB_tpec_TpExPr_show_pane_TPMDL_0}",
  53. "<h1",
  54. "This is a Pane</h1></Pane>",
  55. ]
  56. helpers.test_control_html(gui, html_string, expected_list)