From 71d606f128f0a01986497e386715b47cc4f81d0f Mon Sep 17 00:00:00 2001 From: Toru Seo <34780089+toruseo@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:30:29 +0900 Subject: [PATCH] test update --- .github/workflows/test-gui.yml | 2 +- .github/workflows/verify-module.yml | 5 +- tests/test_result_gui_viewer.py | 79 +++++++++++++++-------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/test-gui.yml b/.github/workflows/test-gui.yml index f82db66..786890e 100644 --- a/.github/workflows/test-gui.yml +++ b/.github/workflows/test-gui.yml @@ -20,5 +20,5 @@ jobs: run: pip install . - name: Install pytest other dependencies run: pip install pytest setuptools - - name: Run verifications with pytest + - name: Run test with pytest run: pytest tests/test_result_gui_viewer.py --durations=0 -v diff --git a/.github/workflows/verify-module.yml b/.github/workflows/verify-module.yml index 2954955..37a6810 100644 --- a/.github/workflows/verify-module.yml +++ b/.github/workflows/verify-module.yml @@ -10,9 +10,6 @@ on: jobs: verify-module: runs-on: ubuntu-latest - strategy: - matrix: - test-script: [tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py tests/test_verification_sioux_falls.py] steps: - uses: actions/checkout@v4 - name: Set up Python 3.12 @@ -24,4 +21,4 @@ jobs: - name: Install pytest other dependencies run: pip install pytest pytest-rerunfailures setuptools - name: Run verifications with pytest - run: pytest ${{ matrix.test-script }} --durations=0 -v + run: pytest tests/test_verification_sioux_falls.py tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py --durations=0 -v -n auto diff --git a/tests/test_result_gui_viewer.py b/tests/test_result_gui_viewer.py index 3bdd294..c673209 100644 --- a/tests/test_result_gui_viewer.py +++ b/tests/test_result_gui_viewer.py @@ -3,41 +3,44 @@ """ import pytest -import uxsim as UX -from uxsim.ResultGUIViewer import ResultGUIViewer - -#simple network -W = UX.World( - name="", # Scenario name - deltan=5, # Simulation aggregation unit delta n - tmax=1200, # Total simulation time (s) - print_mode=1, save_mode=1, show_mode=1, # Various options - random_seed=0 # Set the random seed -) - -# Define the scenario -W.addNode("orig1", 0, 0) # Create a node -W.addNode("orig2", 0, 2) -W.addNode("merge", 0.5, 1) -W.addNode("dest", 1, 1) -W.addLink("link1", "orig1", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=0.5) # Create a link -W.addLink("link2", "orig2", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=2) -W.addLink("link3", "merge", "dest", length=1000, free_flow_speed=20, jam_density=0.2) -W.adddemand("orig1", "dest", 0, 1000, 0.4) # Create OD traffic demand -W.adddemand("orig2", "dest", 500, 1000, 0.6) - - -# Run the simulation to the end -W.exec_simulation() - -# Print summary of simulation result -W.analyzer.print_simple_stats() - -app, window = ResultGUIViewer.launch_World_viewer(W, return_app_window=True) - -from PyQt5.QtCore import QTimer -import sys -timer = QTimer() -timer.timeout.connect(window.close) -timer.start(1000*5) -sys.exit(app.exec_()) \ No newline at end of file + +def test_result_gui_viewer(): + import uxsim as UX + from uxsim.ResultGUIViewer import ResultGUIViewer + + #simple network + W = UX.World( + name="", # Scenario name + deltan=5, # Simulation aggregation unit delta n + tmax=1200, # Total simulation time (s) + print_mode=1, save_mode=1, show_mode=1, # Various options + random_seed=0 # Set the random seed + ) + + # Define the scenario + W.addNode("orig1", 0, 0) # Create a node + W.addNode("orig2", 0, 2) + W.addNode("merge", 0.5, 1) + W.addNode("dest", 1, 1) + W.addLink("link1", "orig1", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=0.5) # Create a link + W.addLink("link2", "orig2", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=2) + W.addLink("link3", "merge", "dest", length=1000, free_flow_speed=20, jam_density=0.2) + W.adddemand("orig1", "dest", 0, 1000, 0.4) # Create OD traffic demand + W.adddemand("orig2", "dest", 500, 1000, 0.6) + + + # Run the simulation to the end + W.exec_simulation() + + # Print summary of simulation result + W.analyzer.print_simple_stats() + + app, window = ResultGUIViewer.launch_World_viewer(W, return_app_window=True) + + # Shut down 5 sec later + from PyQt5.QtCore import QTimer + import sys + timer = QTimer() + timer.timeout.connect(window.close) + timer.start(1000*5) + sys.exit(app.exec_()) \ No newline at end of file