test_number.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_md_width(gui: Gui, helpers):
  28. md_string = "<|10|number|width=70%|>"
  29. expected_list = ["<Input", 'value="10"', 'type="number"', 'width="70%"']
  30. helpers.test_control_md(gui, md_string, expected_list)
  31. def test_number_html_1(gui: Gui, test_client, helpers):
  32. gui._bind_var_val("x", 10)
  33. html_string = '<taipy:number value="{x}" />'
  34. expected_list = [
  35. "<Input",
  36. 'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',
  37. 'defaultValue="10"',
  38. 'type="number"',
  39. "value={_TpN_tpec_TpExPr_x_TPMDL_0}",
  40. ]
  41. helpers.test_control_html(gui, html_string, expected_list)
  42. def test_number_html_2(gui: Gui, test_client, helpers):
  43. gui._bind_var_val("x", 10)
  44. html_string = "<taipy:number>{x}</taipy:number>"
  45. expected_list = [
  46. "<Input",
  47. 'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',
  48. 'defaultValue="10"',
  49. 'type="number"',
  50. "value={_TpN_tpec_TpExPr_x_TPMDL_0}",
  51. ]
  52. helpers.test_control_html(gui, html_string, expected_list)