File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
- from flask import Flask
1
+ from flask import Flask , jsonify
2
2
from routes .book_routes import book
3
3
4
4
app = Flask (__name__ )
10
10
def hello ():
11
11
return {"message" : "Welcome to the Book Management System!" }, 200
12
12
13
+ @app .route ("/health" )
14
+ def health ():
15
+ return jsonify ({"status" : "ok" })
16
+
17
+
13
18
if __name__ == '__main__' :
14
19
app .run (host = '0.0.0.0' , port = 5000 , debug = True )
Original file line number Diff line number Diff line change
1
+ import os
2
+ import sys
3
+ import pytest
4
+
5
+ tests_dir = os .path .dirname (__file__ )
6
+ project_dir = os .path .abspath (os .path .join (tests_dir , os .pardir ))
7
+ sys .path .insert (0 , project_dir )
8
+
9
+ from app import app
10
+
11
+ @pytest .fixture
12
+ def client ():
13
+ app .config ["TESTING" ] = True
14
+ with app .test_client () as client :
15
+ yield client
16
+
17
+ def test_health (client ):
18
+ resp = client .get ("/health" )
19
+ assert resp .status_code == 200
20
+ assert resp .get_json () == {"status" : "ok" }
You can’t perform that action at this time.
0 commit comments