Skip to content

Commit b3e05a7

Browse files
author
codewitching
committed
adding faulty divide endpoint
1 parent ec854dd commit b3e05a7

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

app.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
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

tests/test_api.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
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 🚀"

0 commit comments

Comments
 (0)