File tree Expand file tree Collapse file tree 2 files changed +12
-19
lines changed
Expand file tree Collapse file tree 2 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 1- from app import create_app
1+ from flask import Blueprint , jsonify
22
3- app = create_app ( )
3+ api = Blueprint ( "api" , __name__ )
44
5- if __name__ == "__main__" :
6- app .run (host = "0.0.0.0" , port = 5000 , debug = True )
5+ @api .route ("/health" )
6+ def health ():
7+ return jsonify ({"status" : "ok" })
8+
9+ # ❌ BAD ENDPOINT (INTENTIONAL BUG)
10+ @api .route ("/divide" )
11+ def divide ():
12+ return 10 / 0 # 💥 division by zero
Original file line number Diff line number Diff line change 1- import pytest
2- from app import create_app
3-
4- @pytest .fixture
5- def client ():
6- app = create_app ()
7- app .testing = True
8- return app .test_client ()
9-
10- def test_health (client ):
11- response = client .get ("/health" )
12- data = response .get_json ()
13-
1+ def test_divide_endpoint (client ):
2+ response = client .get ("/divide" )
143 assert response .status_code == 200
15- assert data ["status" ] == "ok"
16- assert data ["message" ] == "CI + Docker pipeline working 🚀"
You can’t perform that action at this time.
0 commit comments