test_number.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_number_md_1(gui: Gui, helpers):
  13. md_string = "<|10|number|>"
  14. expected_list = ["<Input", 'value="10"', 'type="number"']
  15. helpers.test_control_md(gui, md_string, expected_list)
  16. def test_number_md_2(gui: Gui, test_client, helpers):
  17. gui._bind_var_val("x", "10")
  18. md_string = "<|{x}|number|>"
  19. expected_list = [
  20. "<Input",
  21. 'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',
  22. 'defaultValue="10"',
  23. 'type="number"',
  24. "value={_TpN_tpec_TpExPr_x_TPMDL_0}",
  25. ]
  26. helpers.test_control_md(gui, md_string, expected_list)
  27. def test_number_html_1(gui: Gui, test_client, helpers):
  28. gui._bind_var_val("x", 10)
  29. html_string = '<taipy:number value="{x}" />'
  30. expected_list = [
  31. "<Input",
  32. 'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',
  33. 'defaultValue="10"',
  34. 'type="number"',
  35. "value={_TpN_tpec_TpExPr_x_TPMDL_0}",
  36. ]
  37. helpers.test_control_html(gui, html_string, expected_list)
  38. def test_number_html_2(gui: Gui, test_client, helpers):
  39. gui._bind_var_val("x", 10)
  40. html_string = "<taipy:number>{x}</taipy:number>"
  41. expected_list = [
  42. "<Input",
  43. 'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',
  44. 'defaultValue="10"',
  45. 'type="number"',
  46. "value={_TpN_tpec_TpExPr_x_TPMDL_0}",
  47. ]
  48. helpers.test_control_html(gui, html_string, expected_list)