test_accessor_data_format.py 2.4 KB

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