From d35ff308641d86669646220d47823337e65321f5 Mon Sep 17 00:00:00 2001 From: Helldragon67 Date: Thu, 21 Nov 2024 15:36:20 +0100 Subject: [PATCH] better details handling --- .gitea/workflows/backend_run_test.yaml | 1 + backend/src/tests/test_main.py | 29 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/backend_run_test.yaml b/.gitea/workflows/backend_run_test.yaml index 7202949..36b5ee8 100644 --- a/.gitea/workflows/backend_run_test.yaml +++ b/.gitea/workflows/backend_run_test.yaml @@ -33,6 +33,7 @@ jobs: working-directory: backend - name: Upload HTML report + if: always() uses: https://gitea.com/actions/upload-artifact@v3 with: name: pytest-html-report diff --git a/backend/src/tests/test_main.py b/backend/src/tests/test_main.py index 18b465b..4690f41 100644 --- a/backend/src/tests/test_main.py +++ b/backend/src/tests/test_main.py @@ -35,13 +35,8 @@ def test_turckheim(client, request): result = response.json() landmarks = load_trip_landmarks(client, result['first_landmark_uuid']) - # Create the trip string - trip_string = [f"{landmark.name} ({landmark.attractiveness} | {landmark.duration}) - {landmark.time_to_reach_next}" for landmark in landmarks] - - # Pass additional info to pytest for reporting - request.node.trip_details = trip_string - request.node.trip_duration = str(result['total_time']) - request.node.target_duration = str(duration_minutes) + # Add details to report + log_trip_details(request, landmarks, result['total_time'], duration_minutes) # checks : assert response.status_code == 200 # check for successful planning @@ -52,7 +47,7 @@ def test_turckheim(client, request): # Test no. 3 def test_bellecour(client, request) : - duration_minutes = 50 + duration_minutes = 60 response = client.post( "/trip/new", json={ @@ -64,13 +59,8 @@ def test_bellecour(client, request) : landmarks = load_trip_landmarks(client, result['first_landmark_uuid']) osm_ids = landmarks_to_osmid(landmarks) - # Create the trip string - trip_string = [f"{landmark.name} ({landmark.attractiveness}) - {landmark.time_to_reach_next}" for landmark in landmarks] - - # Pass additional info to pytest for reporting - request.node.trip_details = trip_string - request.node.trip_duration = str(result['total_time']) - request.node.target_duration = str(duration_minutes) + # Add details to report + log_trip_details(request, landmarks, result['total_time'], duration_minutes) # checks : assert response.status_code == 200 # check for successful planning @@ -144,6 +134,15 @@ def load_trip_landmarks(client, first_uuid: str) -> List[Landmark]: return landmarks +def log_trip_details(request, landmarks: List[Landmark], duration: int, target_duration: int) : + + # Create the trip string + trip_string = [f"{landmark.name} ({landmark.attractiveness} | {landmark.duration}) - {landmark.time_to_reach_next}" for landmark in landmarks] + + # Pass additional info to pytest for reporting + request.node.trip_details = trip_string + request.node.trip_duration = str(duration) # result['total_time'] + request.node.target_duration = str(target_duration) # def test_new_trip_single_prefs(client):