From f0873ff31337c37cfb0ec82d92798e4cb5969b3a Mon Sep 17 00:00:00 2001 From: Helldragon67 <kilian.scheidecker@orange.fr> Date: Fri, 13 Dec 2024 07:48:39 +0100 Subject: [PATCH] more error checking --- backend/report.html | 4 ++-- backend/src/main.py | 4 +++- backend/src/structs/landmark.py | 2 -- backend/src/tests/test_utils.py | 15 +++++++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/report.html b/backend/report.html index 26a8698..3280295 100644 --- a/backend/report.html +++ b/backend/report.html @@ -328,7 +328,7 @@ div.media { </head> <body> <h1 id="title">Backend Testing Report</h1> - <p>Report generated on 10-Dec-2024 at 16:15:32 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a> + <p>Report generated on 13-Dec-2024 at 07:40:03 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a> v4.1.1</p> <div id="environment-header"> <h2>Environment</h2> @@ -432,7 +432,7 @@ div.media { </table> </body> <footer> - <div id="data-container" data-jsonblob="{"environment": {"Python": "3.12.3", "Platform": "Linux-6.8.0-49-generic-x86_64-with-glibc2.39", "Packages": {"pytest": "8.3.4", "pluggy": "1.5.0"}, "Plugins": {"html": "4.1.1", "metadata": "3.1.1", "anyio": "4.6.2.post1"}}, "tests": {"src/tests/test_invalid_input.py::test_input[start0-preferences0-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start0-preferences0-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start0-preferences0-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">265 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start1-preferences1-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start1-preferences1-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start1-preferences1-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">11 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start2-preferences2-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start2-preferences2-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start2-preferences2-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">11 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start3-preferences3-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start3-preferences3-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start3-preferences3-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">11 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start4-preferences4-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start4-preferences4-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start4-preferences4-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">13 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start5-preferences5-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start5-preferences5-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start5-preferences5-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">13 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start6-preferences6-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start6-preferences6-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start6-preferences6-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">15 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start7-preferences7-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start7-preferences7-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start7-preferences7-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">13 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_main.py::test_turckheim": [{"extras": [], "result": "Passed", "testId": "src/tests/test_main.py::test_turckheim", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_turckheim</td>", "<td>start (0 | 0) - 4 - La Fecht (99 | 5) - 4 - finish (0 | 0) - 0</td>", "<td>13 min</td>", "<td>15 min</td>", "<td class=\"col-duration\">113 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_main.py::test_bellecour": [{"extras": [], "result": "Failed", "testId": "src/tests/test_main.py::test_bellecour", "resultsTableRow": ["<td class=\"col-result\">Failed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_bellecour</td>", "<td>start (0 | 0) - 3 - M\u00e9morial Lyonnais du G\u00e9nocide Arm\u00e9nien (265 | 5) - 4 - \u00c9glise Saint-Fran\u00e7ois-de-Sales (211 | 5) - 4 - Chapelle des J\u00e9suites (161 | 5) - 7 - finish (0 | 0) - 0</td>", "<td>33 min</td>", "<td>30 min</td>", "<td class=\"col-duration\">517 ms</td>", "<td class=\"col-links\"></td>"], "log": "client = &lt;starlette.testclient.TestClient object at 0x7e5970746720&gt;\nrequest = &lt;FixtureRequest for &lt;Function test_bellecour&gt;&gt;\n\n def test_bellecour(client, request) : # pylint: disable=redefined-outer-name\n &quot;&quot;&quot;\n Test n\u00b02 : Custom test in Lyon centre to ensure proper decision making in crowded area.\n \n Args:\n client:\n request:\n &quot;&quot;&quot;\n duration_minutes = 30\n response = client.post(\n &quot;/trip/new&quot;,\n json={\n &quot;preferences&quot;: {&quot;sightseeing&quot;: {&quot;type&quot;: &quot;sightseeing&quot;, &quot;score&quot;: 5},\n &quot;nature&quot;: {&quot;type&quot;: &quot;nature&quot;, &quot;score&quot;: 5},\n &quot;shopping&quot;: {&quot;type&quot;: &quot;shopping&quot;, &quot;score&quot;: 5},\n &quot;max_time_minute&quot;: duration_minutes,\n &quot;detour_tolerance_minute&quot;: 0},\n &quot;start&quot;: [45.7576485, 4.8330241]\n }\n )\n result = response.json()\n landmarks = load_trip_landmarks(client, result[&#x27;first_landmark_uuid&#x27;])\n osm_ids = landmarks_to_osmid(landmarks)\n \n # Add details to report\n log_trip_details(request, landmarks, result[&#x27;total_time&#x27;], duration_minutes)\n \n # checks :\n assert response.status_code == 200 # check for successful planning\n assert duration_minutes*0.8 &lt; int(result[&#x27;total_time&#x27;]) &lt; duration_minutes*1.2\n&gt; assert 136200148 in osm_ids # check for Cath\u00e9drale St. Jean in trip\nE assert 136200148 in [0, 265922306, 82260098, 144904193, 0]\n\nsrc/tests/test_main.py:78: AssertionError\n"}], "src/tests/test_main.py::test_shopping": [{"extras": [], "result": "Failed", "testId": "src/tests/test_main.py::test_shopping", "resultsTableRow": ["<td class=\"col-result\">Failed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_shopping</td>", "<td>start (0 | 0) - 39 - P\u00f4le de Commerces et de Loisirs Confluence (237 | 30) - 47 - Cordeliers (554 | 45) - 8 - Grand H\u00f4tel-Dieu (519 | 30) - 25 - Muji (377 | 30) - 3 - Galeries Lafayette (267 | 30) - 2 - Cour Oxyg\u00e8ne (108 | 30) - 1 - HEMA (195 | 30) - 2 - Westfield La Part-Dieu (598 | 30) - 19 - Chinatown (106 | 45) - 16 - finish (0 | 0) - 0</td>", "<td>462 min</td>", "<td>600 min</td>", "<td class=\"col-duration\">00:00:02</td>", "<td class=\"col-links\"></td>"], "log": "client = &lt;starlette.testclient.TestClient object at 0x7e5970746720&gt;\nrequest = &lt;FixtureRequest for &lt;Function test_shopping&gt;&gt;\n\n def test_shopping(client, request) : # pylint: disable=redefined-outer-name\n &quot;&quot;&quot;\n Test n\u00b03 : Custom test in Lyon centre to ensure shopping clusters are found.\n \n Args:\n client:\n request:\n &quot;&quot;&quot;\n duration_minutes = 600\n response = client.post(\n &quot;/trip/new&quot;,\n json={\n &quot;preferences&quot;: {&quot;sightseeing&quot;: {&quot;type&quot;: &quot;sightseeing&quot;, &quot;score&quot;: 0},\n &quot;nature&quot;: {&quot;type&quot;: &quot;nature&quot;, &quot;score&quot;: 0},\n &quot;shopping&quot;: {&quot;type&quot;: &quot;shopping&quot;, &quot;score&quot;: 5},\n &quot;max_time_minute&quot;: duration_minutes,\n &quot;detour_tolerance_minute&quot;: 0},\n &quot;start&quot;: [45.7576485, 4.8330241]\n }\n )\n result = response.json()\n landmarks = load_trip_landmarks(client, result[&#x27;first_landmark_uuid&#x27;])\n osm_ids = landmarks_to_osmid(landmarks)\n \n # Add details to report\n log_trip_details(request, landmarks, result[&#x27;total_time&#x27;], duration_minutes)\n \n # checks :\n assert response.status_code == 200 # check for successful planning\n&gt; assert duration_minutes*0.8 &lt; int(result[&#x27;total_time&#x27;]) &lt; duration_minutes*1.2\nE assert (600 * 0.8) &lt; 462\nE + where 462 = int(462)\n\nsrc/tests/test_main.py:110: AssertionError\n"}]}, "renderCollapsed": ["passed"], "initialSort": "result", "title": "Backend Testing Report"}"></div> + <div id="data-container" data-jsonblob="{"environment": {"Python": "3.12.3", "Platform": "Linux-6.8.0-50-generic-x86_64-with-glibc2.39", "Packages": {"pytest": "8.3.4", "pluggy": "1.5.0"}, "Plugins": {"html": "4.1.1", "metadata": "3.1.1", "anyio": "4.6.2.post1"}}, "tests": {"src/tests/test_invalid_input.py::test_input[start0-preferences0-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start0-preferences0-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start0-preferences0-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">232 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start1-preferences1-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start1-preferences1-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start1-preferences1-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">6 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start2-preferences2-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start2-preferences2-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start2-preferences2-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">8 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start3-preferences3-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start3-preferences3-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start3-preferences3-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">13 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start4-preferences4-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start4-preferences4-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start4-preferences4-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">13 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start5-preferences5-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start5-preferences5-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start5-preferences5-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">11 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start6-preferences6-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start6-preferences6-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start6-preferences6-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">11 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_invalid_input.py::test_input[start7-preferences7-422]": [{"extras": [], "result": "Passed", "testId": "src/tests/test_invalid_input.py::test_input[start7-preferences7-422]", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_invalid_input.py::test_input[start7-preferences7-422]</td>", "<td>N/A</td>", "<td>N/A</td>", "<td>N/A</td>", "<td class=\"col-duration\">10 ms</td>", "<td class=\"col-links\"></td>"], "log": "No log output captured."}], "src/tests/test_main.py::test_turckheim": [{"extras": [], "result": "Passed", "testId": "src/tests/test_main.py::test_turckheim", "resultsTableRow": ["<td class=\"col-result\">Passed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_turckheim</td>", "<td>start (0 | 0) - 4 - La Fecht (99 | 5) - 4 - finish (0 | 0) - 0</td>", "<td>13 min</td>", "<td>15 min</td>", "<td class=\"col-duration\">65 ms</td>", "<td class=\"col-links\"></td>"], "log": "----------------------------- Captured stdout call -----------------------------\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;start&#x27;, &#x27;type&#x27;: &#x27;start&#x27;, &#x27;location&#x27;: [48.084588, 7.280405], &#x27;osm_type&#x27;: &#x27;start&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;771e3bad-a5ec-4d99-a3d6-6adba854f75f&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 4, &#x27;next_uuid&#x27;: &#x27;f9e96d15-cb47-4c68-a115-b125d395a619&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;La Fecht&#x27;, &#x27;type&#x27;: &#x27;nature&#x27;, &#x27;location&#x27;: [48.0863902, 7.2812045], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 83013892, &#x27;attractiveness&#x27;: 99, &#x27;n_tags&#x27;: 4, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 5, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;f9e96d15-cb47-4c68-a115-b125d395a619&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 4, &#x27;next_uuid&#x27;: &#x27;da682522-afee-4c5b-86c4-0464546b5864&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;finish&#x27;, &#x27;type&#x27;: &#x27;finish&#x27;, &#x27;location&#x27;: [48.084588, 7.280405], &#x27;osm_type&#x27;: &#x27;end&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;da682522-afee-4c5b-86c4-0464546b5864&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 0, &#x27;next_uuid&#x27;: None}\n"}], "src/tests/test_main.py::test_bellecour": [{"extras": [], "result": "Failed", "testId": "src/tests/test_main.py::test_bellecour", "resultsTableRow": ["<td class=\"col-result\">Failed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_bellecour</td>", "<td>start (0 | 0) - 3 - M\u00e9morial Lyonnais du G\u00e9nocide Arm\u00e9nien (265 | 5) - 4 - \u00c9glise Saint-Fran\u00e7ois-de-Sales (211 | 5) - 4 - Chapelle des J\u00e9suites (161 | 5) - 7 - finish (0 | 0) - 0</td>", "<td>33 min</td>", "<td>30 min</td>", "<td class=\"col-duration\">618 ms</td>", "<td class=\"col-links\"></td>"], "log": "client = &lt;starlette.testclient.TestClient object at 0x7f47a1f189b0&gt;\nrequest = &lt;FixtureRequest for &lt;Function test_bellecour&gt;&gt;\n\n def test_bellecour(client, request) : # pylint: disable=redefined-outer-name\n &quot;&quot;&quot;\n Test n\u00b02 : Custom test in Lyon centre to ensure proper decision making in crowded area.\n \n Args:\n client:\n request:\n &quot;&quot;&quot;\n duration_minutes = 30\n response = client.post(\n &quot;/trip/new&quot;,\n json={\n &quot;preferences&quot;: {&quot;sightseeing&quot;: {&quot;type&quot;: &quot;sightseeing&quot;, &quot;score&quot;: 5},\n &quot;nature&quot;: {&quot;type&quot;: &quot;nature&quot;, &quot;score&quot;: 5},\n &quot;shopping&quot;: {&quot;type&quot;: &quot;shopping&quot;, &quot;score&quot;: 5},\n &quot;max_time_minute&quot;: duration_minutes,\n &quot;detour_tolerance_minute&quot;: 0},\n &quot;start&quot;: [45.7576485, 4.8330241]\n }\n )\n result = response.json()\n landmarks = load_trip_landmarks(client, result[&#x27;first_landmark_uuid&#x27;])\n osm_ids = landmarks_to_osmid(landmarks)\n \n # Add details to report\n log_trip_details(request, landmarks, result[&#x27;total_time&#x27;], duration_minutes)\n \n # checks :\n assert response.status_code == 200 # check for successful planning\n assert duration_minutes*0.8 &lt; int(result[&#x27;total_time&#x27;]) &lt; duration_minutes*1.2\n&gt; assert 136200148 in osm_ids # check for Cath\u00e9drale St. Jean in trip\nE assert 136200148 in [0, 265922306, 82260098, 144904193, 0]\n\nsrc/tests/test_main.py:78: AssertionError\n\n----------------------------- Captured stdout call -----------------------------\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;start&#x27;, &#x27;type&#x27;: &#x27;start&#x27;, &#x27;location&#x27;: [45.7576485, 4.8330241], &#x27;osm_type&#x27;: &#x27;start&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;cbf9d10a-84da-4317-afa1-fa8ee370a1b4&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 3, &#x27;next_uuid&#x27;: &#x27;780f0119-78c3-445f-9d39-b0a45f9c316a&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;M\u00e9morial Lyonnais du G\u00e9nocide Arm\u00e9nien&#x27;, &#x27;type&#x27;: &#x27;sightseeing&#x27;, &#x27;location&#x27;: [45.7564328, 4.8340045], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 265922306, &#x27;attractiveness&#x27;: 265, &#x27;n_tags&#x27;: 9, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 5, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;780f0119-78c3-445f-9d39-b0a45f9c316a&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 4, &#x27;next_uuid&#x27;: &#x27;9022486e-76d0-4a7a-900e-91c6a16c46e5&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;\u00c9glise Saint-Fran\u00e7ois-de-Sales&#x27;, &#x27;type&#x27;: &#x27;sightseeing&#x27;, &#x27;location&#x27;: [45.7553013, 4.8318315], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 82260098, &#x27;attractiveness&#x27;: 211, &#x27;n_tags&#x27;: 9, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 5, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;9022486e-76d0-4a7a-900e-91c6a16c46e5&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 4, &#x27;next_uuid&#x27;: &#x27;b9512def-188f-422b-a995-8181f7d3f933&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Chapelle des J\u00e9suites&#x27;, &#x27;type&#x27;: &#x27;sightseeing&#x27;, &#x27;location&#x27;: [45.7558343, 4.8287635], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 144904193, &#x27;attractiveness&#x27;: 161, &#x27;n_tags&#x27;: 8, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 5, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;b9512def-188f-422b-a995-8181f7d3f933&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 7, &#x27;next_uuid&#x27;: &#x27;0a0e8d05-b1c2-49ed-add0-03e1532c1895&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;finish&#x27;, &#x27;type&#x27;: &#x27;finish&#x27;, &#x27;location&#x27;: [45.7576485, 4.8330241], &#x27;osm_type&#x27;: &#x27;end&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;0a0e8d05-b1c2-49ed-add0-03e1532c1895&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 0, &#x27;next_uuid&#x27;: None}\n"}], "src/tests/test_main.py::test_shopping": [{"extras": [], "result": "Failed", "testId": "src/tests/test_main.py::test_shopping", "resultsTableRow": ["<td class=\"col-result\">Failed</td>", "<td class=\"col-testId\">src/tests/test_main.py::test_shopping</td>", "<td>start (0 | 0) - 39 - P\u00f4le de Commerces et de Loisirs Confluence (237 | 30) - 47 - Cordeliers (554 | 45) - 8 - Grand H\u00f4tel-Dieu (519 | 30) - 25 - Muji (377 | 30) - 3 - Galeries Lafayette (267 | 30) - 2 - Cour Oxyg\u00e8ne (108 | 30) - 1 - HEMA (195 | 30) - 2 - Westfield La Part-Dieu (598 | 30) - 19 - Chinatown (106 | 45) - 16 - finish (0 | 0) - 0</td>", "<td>462 min</td>", "<td>600 min</td>", "<td class=\"col-duration\">00:00:02</td>", "<td class=\"col-links\"></td>"], "log": "client = &lt;starlette.testclient.TestClient object at 0x7f47a1f189b0&gt;\nrequest = &lt;FixtureRequest for &lt;Function test_shopping&gt;&gt;\n\n def test_shopping(client, request) : # pylint: disable=redefined-outer-name\n &quot;&quot;&quot;\n Test n\u00b03 : Custom test in Lyon centre to ensure shopping clusters are found.\n \n Args:\n client:\n request:\n &quot;&quot;&quot;\n duration_minutes = 600\n response = client.post(\n &quot;/trip/new&quot;,\n json={\n &quot;preferences&quot;: {&quot;sightseeing&quot;: {&quot;type&quot;: &quot;sightseeing&quot;, &quot;score&quot;: 0},\n &quot;nature&quot;: {&quot;type&quot;: &quot;nature&quot;, &quot;score&quot;: 0},\n &quot;shopping&quot;: {&quot;type&quot;: &quot;shopping&quot;, &quot;score&quot;: 5},\n &quot;max_time_minute&quot;: duration_minutes,\n &quot;detour_tolerance_minute&quot;: 0},\n &quot;start&quot;: [45.7576485, 4.8330241]\n }\n )\n result = response.json()\n landmarks = load_trip_landmarks(client, result[&#x27;first_landmark_uuid&#x27;])\n # osm_ids = landmarks_to_osmid(landmarks)\n \n # Add details to report\n log_trip_details(request, landmarks, result[&#x27;total_time&#x27;], duration_minutes)\n \n # checks :\n assert response.status_code == 200 # check for successful planning\n&gt; assert duration_minutes*0.8 &lt; int(result[&#x27;total_time&#x27;]) &lt; duration_minutes*1.2\nE assert (600 * 0.8) &lt; 462\nE + where 462 = int(462)\n\nsrc/tests/test_main.py:110: AssertionError\n\n----------------------------- Captured stdout call -----------------------------\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;start&#x27;, &#x27;type&#x27;: &#x27;start&#x27;, &#x27;location&#x27;: [45.7576485, 4.8330241], &#x27;osm_type&#x27;: &#x27;start&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;9159196c-1b76-4b08-9fa6-320b5c6bd36e&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 39, &#x27;next_uuid&#x27;: &#x27;0f8d985b-3d4a-473e-955d-61fee443f990&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;P\u00f4le de Commerces et de Loisirs Confluence&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7410414, 4.8171031], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 440270633, &#x27;attractiveness&#x27;: 237, &#x27;n_tags&#x27;: 14, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;https://www.confluence.fr/&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;0f8d985b-3d4a-473e-955d-61fee443f990&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 47, &#x27;next_uuid&#x27;: &#x27;065eaaef-c25d-43c1-baf5-46bbb784613b&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Cordeliers&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.762186042960266, 4.833812418411551], &#x27;osm_type&#x27;: &#x27;node&#x27;, &#x27;osm_id&#x27;: 5545183519, &#x27;attractiveness&#x27;: 554, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 45, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;065eaaef-c25d-43c1-baf5-46bbb784613b&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 8, &#x27;next_uuid&#x27;: &#x27;96ce818e-b82a-4902-8c90-b38e6167388d&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Grand H\u00f4tel-Dieu&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7586955, 4.8364597], &#x27;osm_type&#x27;: &#x27;relation&#x27;, &#x27;osm_id&#x27;: 300128, &#x27;attractiveness&#x27;: 519, &#x27;n_tags&#x27;: 22, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;https://grand-hotel-dieu.com&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;96ce818e-b82a-4902-8c90-b38e6167388d&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 25, &#x27;next_uuid&#x27;: &#x27;f7f4fc59-de56-40d8-acf6-a2649ab0d689&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Muji&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7615971, 4.8543781], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 1044165817, &#x27;attractiveness&#x27;: 377, &#x27;n_tags&#x27;: 14, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;https://www.muji.com/fr/&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: &#x27;Muji&#x27;, &#x27;uuid&#x27;: &#x27;f7f4fc59-de56-40d8-acf6-a2649ab0d689&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 3, &#x27;next_uuid&#x27;: &#x27;ea4ece0e-ef51-4234-8019-5bded852538f&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Galeries Lafayette&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7627107, 4.8556833], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 1069872743, &#x27;attractiveness&#x27;: 267, &#x27;n_tags&#x27;: 11, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;http://www.galerieslafayette.com/&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;ea4ece0e-ef51-4234-8019-5bded852538f&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 2, &#x27;next_uuid&#x27;: &#x27;0ba74af7-6f73-4fac-b5b4-952cfac4a8cb&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Cour Oxyg\u00e8ne&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7620905, 4.8568873], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 132673030, &#x27;attractiveness&#x27;: 108, &#x27;n_tags&#x27;: 6, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;0ba74af7-6f73-4fac-b5b4-952cfac4a8cb&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 1, &#x27;next_uuid&#x27;: &#x27;48db71e4-e0cb-497b-82fb-56c092ce9b8b&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;HEMA&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7619133, 4.8565239], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 1069872750, &#x27;attractiveness&#x27;: 195, &#x27;n_tags&#x27;: 9, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;https://fr.westfield.com/lapartdieu/store/HEMA/www.hema.fr&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;48db71e4-e0cb-497b-82fb-56c092ce9b8b&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 2, &#x27;next_uuid&#x27;: &#x27;23d841eb-f1aa-4a3a-bf3a-7401dd6e5f4b&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Westfield La Part-Dieu&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.761331, 4.855676], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 62338376, &#x27;attractiveness&#x27;: 598, &#x27;n_tags&#x27;: 23, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: &#x27;https://fr.westfield.com/lapartdieu&#x27;, &#x27;description&#x27;: None, &#x27;duration&#x27;: 30, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;23d841eb-f1aa-4a3a-bf3a-7401dd6e5f4b&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 19, &#x27;next_uuid&#x27;: &#x27;00152252-843d-40cb-b8fe-b80455f7fde7&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;Chinatown&#x27;, &#x27;type&#x27;: &#x27;shopping&#x27;, &#x27;location&#x27;: [45.7555139490566, 4.84416276981132], &#x27;osm_type&#x27;: &#x27;way&#x27;, &#x27;osm_id&#x27;: 996515596, &#x27;attractiveness&#x27;: 106, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 45, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;00152252-843d-40cb-b8fe-b80455f7fde7&#x27;, &#x27;must_do&#x27;: False, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 16, &#x27;next_uuid&#x27;: &#x27;82f03711-9d01-4c2e-8977-193e3c6aa780&#x27;}\nAPI Response of type &lt;class &#x27;dict&#x27;&gt; in json format: {&#x27;name&#x27;: &#x27;finish&#x27;, &#x27;type&#x27;: &#x27;finish&#x27;, &#x27;location&#x27;: [45.7576485, 4.8330241], &#x27;osm_type&#x27;: &#x27;end&#x27;, &#x27;osm_id&#x27;: 0, &#x27;attractiveness&#x27;: 0, &#x27;n_tags&#x27;: 0, &#x27;image_url&#x27;: None, &#x27;website_url&#x27;: None, &#x27;description&#x27;: None, &#x27;duration&#x27;: 0, &#x27;name_en&#x27;: None, &#x27;uuid&#x27;: &#x27;82f03711-9d01-4c2e-8977-193e3c6aa780&#x27;, &#x27;must_do&#x27;: True, &#x27;must_avoid&#x27;: False, &#x27;is_secondary&#x27;: False, &#x27;time_to_reach_next&#x27;: 0, &#x27;next_uuid&#x27;: None}\n"}]}, "renderCollapsed": ["passed"], "initialSort": "result", "title": "Backend Testing Report"}"></div> <script> (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ const { getCollapsedCategory, setCollapsedIds } = require('./storage.js') diff --git a/backend/src/main.py b/backend/src/main.py index 9961178..2492f32 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -69,7 +69,7 @@ def new_trip(preferences: Preferences, osm_id=0, attractiveness=0, must_do=True, - n_tags = 0) + n_tags=0) # Generate the landmarks from the start location landmarks, landmarks_short = manager.generate_landmarks_list( @@ -132,6 +132,8 @@ def get_landmark(landmark_uuid: str) -> Landmark: """ try: landmark = cache_client.get(f"landmark_{landmark_uuid}") + if not isinstance(landmark, Landmark) : + raise ValueError(f"Object {landmark} is not of type Landmark") return landmark except KeyError as exc: raise HTTPException(status_code=404, detail="Landmark not found") from exc diff --git a/backend/src/structs/landmark.py b/backend/src/structs/landmark.py index b5c1070..85eb996 100644 --- a/backend/src/structs/landmark.py +++ b/backend/src/structs/landmark.py @@ -73,8 +73,6 @@ class Landmark(BaseModel) : t_to_next_str = f", time_to_next={self.time_to_reach_next}" if self.time_to_reach_next else "" is_secondary_str = ", secondary" if self.is_secondary else "" type_str = '(' + self.type + ')' - if self.type in ["start", "finish", "nature", "shopping"] : - type_str += '\t ' return (f'Landmark{type_str}: [{self.name} @{self.location}, ' f'score={self.attractiveness}{t_to_next_str}{is_secondary_str}]') diff --git a/backend/src/tests/test_utils.py b/backend/src/tests/test_utils.py index c3cec6a..f36bb33 100644 --- a/backend/src/tests/test_utils.py +++ b/backend/src/tests/test_utils.py @@ -1,4 +1,5 @@ """Helper methods for testing.""" +import logging from typing import List from fastapi import HTTPException @@ -31,17 +32,23 @@ def fetch_landmark(client, landmark_uuid: str): Returns: dict: Landmark data fetched from the API. """ + logger = logging.getLogger(__name__) response = client.get(f"/landmark/{landmark_uuid}") if response.status_code != 200: - raise HTTPException(status_code=999, + raise HTTPException(status_code=500, detail=f"Failed to fetch landmark with UUID {landmark_uuid}: {response.status_code}") - json_data = response.json() + try: + json_data = response.json() + logger.info(f"API Response: {json_data}") + print(f"API Response of type {type(json_data)} in json format: {json_data}") + except ValueError as e: + logger.error(f"Failed to parse response as JSON: {response.text}") + raise HTTPException(status_code=500, detail="Invalid response format from API") if "detail" in json_data: - raise HTTPException(status_code=999, detail=json_data["detail"]) - + raise HTTPException(status_code=500, detail=json_data["detail"]) return json_data