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:
parent
881f6a901d
commit
840eb40247
@ -29,5 +29,11 @@ jobs:
|
||||
working-directory: backend
|
||||
|
||||
- name: Run Tests
|
||||
run: pipenv run pytest src
|
||||
run: pipenv run pytest src --html=report.html --self-contained-html
|
||||
working-directory: backend
|
||||
|
||||
- name: Upload HTML report
|
||||
uses: https://gitea.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: pytest-html-report
|
||||
path: report.html
|
||||
|
@ -9,6 +9,7 @@ pytest = "*"
|
||||
tomli = "*"
|
||||
httpx = "*"
|
||||
exceptiongroup = "*"
|
||||
pytest-html = "*"
|
||||
|
||||
[packages]
|
||||
numpy = "*"
|
||||
|
108
backend/Pipfile.lock
generated
108
backend/Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "4f5f640531306a5b25610a89686ea4cc61c1381a42442e09edc89dc2c65e9798"
|
||||
"sha256": "2b63ee95d92465adc00e3404e19b55c21604867bcdb0f4e349c595e891a895b1"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
@ -1300,26 +1300,26 @@
|
||||
},
|
||||
"starlette": {
|
||||
"hashes": [
|
||||
"sha256:9834fd799d1a87fd346deb76158668cfa0b0d56f85caefe8268e2d97c3468b62",
|
||||
"sha256:fbc189474b4731cf30fcef52f18a8d070e3f3b46c6a04c97579e85e6ffca942d"
|
||||
"sha256:0e4ab3d16522a255be6b28260b938eae2482f98ce5cc934cb08dce8dc3ba5835",
|
||||
"sha256:44cedb2b7c77a9de33a8b74b2b90e9f50d11fcf25d8270ea525ad71a25374ff7"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==0.41.2"
|
||||
"version": "==0.41.3"
|
||||
},
|
||||
"typer": {
|
||||
"hashes": [
|
||||
"sha256:d85fe0b777b2517cc99c8055ed735452f2659cd45e451507c76f48ce5c1d00e2",
|
||||
"sha256:f1c7198347939361eec90139ffa0fd8b3df3a2259d5852a0f7400e476d95985c"
|
||||
"sha256:5b59580fd925e89463a29d363e0a43245ec02765bde9fb77d39e5d0f29dd7157",
|
||||
"sha256:9d444cb96cc268ce6f8b94e13b4335084cef4c079998a9f4851a90229a3bd25c"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==0.13.0"
|
||||
"version": "==0.13.1"
|
||||
},
|
||||
"typing-extensions": {
|
||||
"hashes": [
|
||||
"sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d",
|
||||
"sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"markers": "python_version < '3.13'",
|
||||
"version": "==4.12.2"
|
||||
},
|
||||
"tzdata": {
|
||||
@ -1737,6 +1737,81 @@
|
||||
"markers": "python_full_version >= '3.8.0'",
|
||||
"version": "==5.13.2"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369",
|
||||
"sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==3.1.4"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4",
|
||||
"sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30",
|
||||
"sha256:1225beacc926f536dc82e45f8a4d68502949dc67eea90eab715dea3a21c1b5f0",
|
||||
"sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9",
|
||||
"sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396",
|
||||
"sha256:1a9d3f5f0901fdec14d8d2f66ef7d035f2157240a433441719ac9a3fba440b13",
|
||||
"sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028",
|
||||
"sha256:1e084f686b92e5b83186b07e8a17fc09e38fff551f3602b249881fec658d3eca",
|
||||
"sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557",
|
||||
"sha256:2cb8438c3cbb25e220c2ab33bb226559e7afb3baec11c4f218ffa7308603c832",
|
||||
"sha256:3169b1eefae027567d1ce6ee7cae382c57fe26e82775f460f0b2778beaad66c0",
|
||||
"sha256:3809ede931876f5b2ec92eef964286840ed3540dadf803dd570c3b7e13141a3b",
|
||||
"sha256:38a9ef736c01fccdd6600705b09dc574584b89bea478200c5fbf112a6b0d5579",
|
||||
"sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a",
|
||||
"sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c",
|
||||
"sha256:48032821bbdf20f5799ff537c7ac3d1fba0ba032cfc06194faffa8cda8b560ff",
|
||||
"sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c",
|
||||
"sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22",
|
||||
"sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094",
|
||||
"sha256:57cb5a3cf367aeb1d316576250f65edec5bb3be939e9247ae594b4bcbc317dfb",
|
||||
"sha256:5b02fb34468b6aaa40dfc198d813a641e3a63b98c2b05a16b9f80b7ec314185e",
|
||||
"sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5",
|
||||
"sha256:6af100e168aa82a50e186c82875a5893c5597a0c1ccdb0d8b40240b1f28b969a",
|
||||
"sha256:6c89876f41da747c8d3677a2b540fb32ef5715f97b66eeb0c6b66f5e3ef6f59d",
|
||||
"sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a",
|
||||
"sha256:70a87b411535ccad5ef2f1df5136506a10775d267e197e4cf531ced10537bd6b",
|
||||
"sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8",
|
||||
"sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225",
|
||||
"sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c",
|
||||
"sha256:88b49a3b9ff31e19998750c38e030fc7bb937398b1f78cfa599aaef92d693144",
|
||||
"sha256:8c4e8c3ce11e1f92f6536ff07154f9d49677ebaaafc32db9db4620bc11ed480f",
|
||||
"sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87",
|
||||
"sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d",
|
||||
"sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93",
|
||||
"sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf",
|
||||
"sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158",
|
||||
"sha256:a123e330ef0853c6e822384873bef7507557d8e4a082961e1defa947aa59ba84",
|
||||
"sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb",
|
||||
"sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48",
|
||||
"sha256:b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171",
|
||||
"sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c",
|
||||
"sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6",
|
||||
"sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd",
|
||||
"sha256:bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d",
|
||||
"sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1",
|
||||
"sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d",
|
||||
"sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca",
|
||||
"sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a",
|
||||
"sha256:cfad01eed2c2e0c01fd0ecd2ef42c492f7f93902e39a42fc9ee1692961443a29",
|
||||
"sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe",
|
||||
"sha256:d8213e09c917a951de9d09ecee036d5c7d36cb6cb7dbaece4c71a60d79fb9798",
|
||||
"sha256:e07c3764494e3776c602c1e78e298937c3315ccc9043ead7e685b7f2b8d47b3c",
|
||||
"sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8",
|
||||
"sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f",
|
||||
"sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f",
|
||||
"sha256:eaa0a10b7f72326f1372a713e73c3f739b524b3af41feb43e4921cb529f5929a",
|
||||
"sha256:eb7972a85c54febfb25b5c4b4f3af4dcc731994c7da0d8a0b4a6eb0640e1d178",
|
||||
"sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0",
|
||||
"sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79",
|
||||
"sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430",
|
||||
"sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50"
|
||||
],
|
||||
"markers": "python_version >= '3.9'",
|
||||
"version": "==3.0.2"
|
||||
},
|
||||
"mccabe": {
|
||||
"hashes": [
|
||||
"sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325",
|
||||
@ -1787,6 +1862,23 @@
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==8.3.3"
|
||||
},
|
||||
"pytest-html": {
|
||||
"hashes": [
|
||||
"sha256:70a01e8ae5800f4a074b56a4cb1025c8f4f9b038bba5fe31e3c98eb996686f07",
|
||||
"sha256:c8152cea03bd4e9bee6d525573b67bbc6622967b72b9628dda0ea3e2a0b5dd71"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==4.1.1"
|
||||
},
|
||||
"pytest-metadata": {
|
||||
"hashes": [
|
||||
"sha256:c8e0844db684ee1c798cfa38908d20d67d0463ecb6137c72e91f418558dd5f4b",
|
||||
"sha256:d2a29b0355fbc03f168aa96d41ff88b1a3b44a3b02acbe491801c98a048017c8"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==3.1.1"
|
||||
},
|
||||
"sniffio": {
|
||||
"hashes": [
|
||||
"sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2",
|
||||
|
47
backend/conftest.py
Normal file
47
backend/conftest.py
Normal file
@ -0,0 +1,47 @@
|
||||
import pytest
|
||||
|
||||
pytest_plugins = ["pytest_html"]
|
||||
|
||||
def pytest_html_report_title(report):
|
||||
"""modifying the title of html report"""
|
||||
report.title = "Backend Testing Report"
|
||||
|
||||
def pytest_html_results_table_header(cells):
|
||||
cells.insert(2, "<th>Detailed trip</th>")
|
||||
cells.insert(3, "<th>Trip Duration</th>")
|
||||
cells.insert(4, "<th>Target Duration</th>")
|
||||
cells[5] = "<th>Execution time</th>" # rename the column containing execution times to avoid confusion
|
||||
|
||||
|
||||
def pytest_html_results_table_row(report, cells):
|
||||
trip_details = getattr(report, "trip_details", "N/A") # Default to "N/A" if no trip data
|
||||
trip_duration = getattr(report, "trip_duration", "N/A") # Default to "N/A" if no trip data
|
||||
target_duration = getattr(report, "target_duration", "N/A") # Default to "N/A" if no trip data
|
||||
cells.insert(2, f"<td>{trip_details}</td>")
|
||||
cells.insert(3, f"<td>{trip_duration}</td>")
|
||||
cells.insert(4, f"<td>{target_duration}</td>")
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
outcome = yield
|
||||
report = outcome.get_result()
|
||||
report.description = str(item.function.__doc__)
|
||||
|
||||
# Attach trip_details if it exists
|
||||
if hasattr(item, "trip_details"):
|
||||
report.trip_details = " - ".join(item.trip_details) # Convert list to string
|
||||
else:
|
||||
report.trip_details = "N/A" # Default if trip_string is not set
|
||||
|
||||
# Attach trip_duration if it exists
|
||||
if hasattr(item, "trip_duration"):
|
||||
report.trip_duration = item.trip_duration + " min"
|
||||
else:
|
||||
report.trip_duration = "N/A" # Default if duration is not set
|
||||
|
||||
# Attach target_duration if it exists
|
||||
if hasattr(item, "target_duration"):
|
||||
report.target_duration = item.target_duration + " min"
|
||||
else:
|
||||
report.target_duration = "N/A" # Default if duration is not set
|
1094
backend/report.html
Normal file
1094
backend/report.html
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user