test_button.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_button_md_1(gui: Gui, test_client, helpers):
  13. gui._bind_var_val("name", "World!")
  14. gui._bind_var_val("btn_id", "button1")
  15. md_string = "<|Hello {name}|button|id={btn_id}|>"
  16. expected_list = ["<Button", 'defaultLabel="Hello World!"', "label={tp_TpExPr_Hello_name_TPMDL_0_0"]
  17. helpers.test_control_md(gui, md_string, expected_list)
  18. def test_button_md_2(gui: Gui, test_client, helpers):
  19. gui._bind_var_val("name", "World!")
  20. gui._bind_var_val("btn_id", "button1")
  21. md_string = "<|button|label=Hello {name}|id={btn_id}|>"
  22. expected_list = ["<Button", 'defaultLabel="Hello World!"', "label={tp_TpExPr_Hello_name_TPMDL_0_0"]
  23. helpers.test_control_md(gui, md_string, expected_list)
  24. def test_button_html_1(gui: Gui, test_client, helpers):
  25. gui._bind_var_val("name", "World!")
  26. gui._bind_var_val("btn_id", "button1")
  27. html_string = '<taipy:button label="Hello {name}" id="{btn_id}" />'
  28. expected_list = ["<Button", 'defaultLabel="Hello World!"', "label={tp_TpExPr_Hello_name_TPMDL_0_0"]
  29. helpers.test_control_html(gui, html_string, expected_list)
  30. def test_button_html_2(gui: Gui, test_client, helpers):
  31. gui._bind_var_val("name", "World!")
  32. gui._bind_var_val("btn_id", "button1")
  33. html_string = '<taipy:button id="{btn_id}">Hello {name}</taipy:button>'
  34. expected_list = ["<Button", 'defaultLabel="Hello World!"', "label={tp_TpExPr_Hello_name_TPMDL_0_0"]
  35. helpers.test_control_html(gui, html_string, expected_list)