test_input.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2021-2025 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. import inspect
  12. import taipy.gui.builder as tgb
  13. from taipy.gui import Gui
  14. def test_input_builder(gui: Gui, helpers):
  15. x = "Hello World!" # noqa: F841
  16. gui._set_frame(inspect.currentframe())
  17. with tgb.Page(frame=None) as page:
  18. tgb.input(value="{x}") # type: ignore[attr-defined]
  19. expected_list = [
  20. "<Input",
  21. 'updateVarName="tpec_TpExPr_x_TPMDL_0"',
  22. 'defaultValue="Hello World!"',
  23. 'type="text"',
  24. "value={tpec_TpExPr_x_TPMDL_0}",
  25. ]
  26. helpers.test_control_builder(gui, page, expected_list)
  27. def test_password_builder(gui: Gui, helpers):
  28. x = "Hello World!" # noqa: F841
  29. gui._set_frame(inspect.currentframe())
  30. with tgb.Page(frame=None) as page:
  31. tgb.input(value="{x}", password=True) # type: ignore[attr-defined]
  32. expected_list = [
  33. "<Input",
  34. 'updateVarName="tpec_TpExPr_x_TPMDL_0"',
  35. 'defaultValue="Hello World!"',
  36. 'type="password"',
  37. "value={tpec_TpExPr_x_TPMDL_0}",
  38. ]
  39. helpers.test_control_builder(gui, page, expected_list)