test_multiple_instances.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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. from taipy.gui.gui import Gui
  12. def test_multiple_instance(gui_server, helpers):
  13. gui1 = Gui("<|gui1|>", server=gui_server)
  14. gui2 = Gui("<|gui2|>", server=gui_server)
  15. gui1.run(run_server=False)
  16. gui2.run(run_server=False)
  17. client1 = gui1._server.test_client()
  18. client2 = gui2._server.test_client()
  19. assert_multiple_instance(client1, helpers, 'value="gui1"')
  20. assert_multiple_instance(client2, helpers, 'value="gui2"')
  21. def assert_multiple_instance(client, helpers, expected_value):
  22. response = client.get("/taipy-jsx/TaiPy_root_page")
  23. response_data = helpers.get_response_data(response)
  24. assert response.status_code == 200
  25. assert isinstance(response_data, dict)
  26. assert "jsx" in response_data
  27. assert expected_value in response_data["jsx"]