test_input.py 1.7 KB

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