test_accessor_data_format.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. from importlib import util
  13. import pytest
  14. if util.find_spec("playwright"):
  15. from playwright._impl._page import Page
  16. from taipy.gui import Gui
  17. @pytest.mark.teste2e
  18. def test_accessor_json(page: "Page", gui: Gui, csvdata, helpers):
  19. table_data = csvdata # noqa: F841
  20. gui._set_frame(inspect.currentframe())
  21. gui.add_page(
  22. name="test",
  23. page="<|{table_data}|table|columns=Day;Entity;Code;Daily hospital occupancy|date_format=eee dd MMM yyyy|id=table1|>", # noqa: E501
  24. )
  25. helpers.run_e2e(gui, use_arrow=False)
  26. page.goto("./test")
  27. page.expect_websocket()
  28. page.wait_for_selector("#table1 tr:nth-child(32)") # wait for data to be loaded (30 rows of skeleton while loading)
  29. assert_table_content(page)
  30. @pytest.mark.teste2e
  31. def test_accessor_arrow(page: "Page", gui: Gui, csvdata, helpers):
  32. if util.find_spec("pyarrow"):
  33. table_data = csvdata # noqa: F841
  34. gui._set_frame(inspect.currentframe())
  35. gui.add_page(
  36. name="test",
  37. page="<|{table_data}|table|columns=Day;Entity;Code;Daily hospital occupancy|date_format=eee dd MMM yyyy|id=table1|>", # noqa: E501
  38. )
  39. helpers.run_e2e(gui, use_arrow=True)
  40. page.goto("./test")
  41. page.expect_websocket()
  42. page.wait_for_selector(
  43. "#table1 tr:nth-child(32)"
  44. ) # wait for data to be loaded (30 rows of skeleton while loading)
  45. assert_table_content(page)
  46. def assert_table_content(page: "Page"):
  47. # assert page.query_selector("#table1 tbody tr:nth-child(1) td:nth-child(1)").inner_text() == "Wed 01 Apr 2020"
  48. assert page.query_selector("#table1 tbody tr:nth-child(1) td:nth-child(2)").inner_text() == "Austria"
  49. assert page.query_selector("#table1 tbody tr:nth-child(1) td:nth-child(4)").inner_text() == "856"