From efb46fcb80ff8913bf08d66fb385508bc253ff12 Mon Sep 17 00:00:00 2001 From: klu2300031947 <163754507+klu2300031947@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:54:29 +0530 Subject: [PATCH] Update test_routes.py Add LIST BY NAME route test case to test_routes.py --- tests/test_routes.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/test_routes.py b/tests/test_routes.py index cce7315..05100e5 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -1,6 +1,4 @@ -from flask import Flask -import json - +from flask import Flask, json from flask_pytest_example.handlers.routes import configure_routes @@ -71,3 +69,18 @@ def test_post_route__failure__bad_request(): response = client.post(url, data=json.dumps(mock_request_data), headers=mock_request_headers) assert response.status_code == 400 + + +# LIST BY NAME test case +def test_list_by_name_route__success(): + app = Flask(__name__) + configure_routes(app) + client = app.test_client() + url = '/list/name/JohnDoe' # Replace 'JohnDoe' with the actual name you are filtering by + + response = client.get(url) + data = json.loads(response.get_data(as_text=True)) + + assert response.status_code == 200 + assert isinstance(data, dict) # Ensure response is a dictionary with details + assert data.get('name') == 'JohnDoe' # Check that the returned name matches