auto test report
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m57s
Run linting on the backend code / Build (pull_request) Failing after 25s
Run testing on the backend code / Build (pull_request) Failing after 1m11s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 20s
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m57s
Run linting on the backend code / Build (pull_request) Failing after 25s
Run testing on the backend code / Build (pull_request) Failing after 1m11s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 20s
This commit is contained in:
@@ -22,8 +22,8 @@ def test_new_trip_invalid_prefs(client):
|
||||
assert response.status_code == 422
|
||||
|
||||
|
||||
# Test no. 1
|
||||
def test_turckheim(client):
|
||||
# Test no. 2
|
||||
def test_turckheim(client, request):
|
||||
duration_minutes = 15
|
||||
response = client.post(
|
||||
"/trip/new",
|
||||
@@ -35,6 +35,14 @@ def test_turckheim(client):
|
||||
result = response.json()
|
||||
landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
|
||||
|
||||
# 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)
|
||||
|
||||
# checks :
|
||||
assert response.status_code == 200 # check for successful planning
|
||||
assert isinstance(landmarks, list) # check that the return type is a list
|
||||
@@ -42,8 +50,8 @@ def test_turckheim(client):
|
||||
assert len(landmarks) > 2 # check that there is something to visit
|
||||
|
||||
|
||||
# Test no. 2
|
||||
def test_bellecour(client) :
|
||||
# Test no. 3
|
||||
def test_bellecour(client, request) :
|
||||
duration_minutes = 35
|
||||
response = client.post(
|
||||
"/trip/new",
|
||||
@@ -56,6 +64,14 @@ def test_bellecour(client) :
|
||||
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)
|
||||
|
||||
# checks :
|
||||
assert response.status_code == 200 # check for successful planning
|
||||
assert duration_minutes*0.8 < int(result['total_time']) < duration_minutes*1.2
|
||||
@@ -63,7 +79,7 @@ def test_bellecour(client) :
|
||||
|
||||
|
||||
|
||||
def landmarks_to_osmid(landmarks: List[Landmark]) -> list :
|
||||
def landmarks_to_osmid(landmarks: List[Landmark]) -> List[int] :
|
||||
"""
|
||||
Convert the list of landmarks into a list containing their osm ids for quick landmark checking.
|
||||
|
||||
@@ -79,7 +95,7 @@ def landmarks_to_osmid(landmarks: List[Landmark]) -> list :
|
||||
|
||||
return ids
|
||||
|
||||
def fetch_landmark(client, landmark_uuid):
|
||||
def fetch_landmark(client, landmark_uuid: str):
|
||||
"""
|
||||
Fetch landmark data from the API based on the landmark UUID.
|
||||
|
||||
@@ -102,7 +118,7 @@ def fetch_landmark(client, landmark_uuid):
|
||||
return json_data
|
||||
|
||||
|
||||
def load_trip_landmarks(client, first_uuid):
|
||||
def load_trip_landmarks(client, first_uuid: str) -> List[Landmark]:
|
||||
"""
|
||||
Load all landmarks for a trip using the response from the API.
|
||||
|
||||
@@ -117,6 +133,11 @@ def load_trip_landmarks(client, first_uuid):
|
||||
|
||||
while next_uuid is not None:
|
||||
landmark_data = fetch_landmark(client, next_uuid)
|
||||
# # Convert UUIDs to strings explicitly
|
||||
# landmark_data = {
|
||||
# key: str(value) if isinstance(value, UUID) else value
|
||||
# for key, value in landmark_data.items()
|
||||
# }
|
||||
landmarks.append(Landmark(**landmark_data)) # Create Landmark objects
|
||||
next_uuid = landmark_data.get('next_uuid') # Prepare for the next iteration
|
||||
|
||||
|
Reference in New Issue
Block a user