Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion flask-redis/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask
from flask import Flask, jsonify
from routes.book_routes import book

app = Flask(__name__)
Expand All @@ -10,5 +10,10 @@
def hello():
return {"message": "Welcome to the Book Management System!"}, 200

@app.route("/health")
def health():
return jsonify({"status": "ok"})


if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
20 changes: 20 additions & 0 deletions flask-redis/tests/test_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import sys
import pytest

tests_dir = os.path.dirname(__file__)
project_dir = os.path.abspath(os.path.join(tests_dir, os.pardir))
sys.path.insert(0, project_dir)

from app import app

@pytest.fixture
def client():
app.config["TESTING"] = True
with app.test_client() as client:
yield client

def test_health(client):
resp = client.get("/health")
assert resp.status_code == 200
assert resp.get_json() == {"status": "ok"}