Ved Gupta commited on
Commit
9fd370e
·
1 Parent(s): 8746e99

ping:pong added

Browse files
app/main.py CHANGED
@@ -1,8 +1,9 @@
1
  from fastapi import FastAPI
 
 
2
  from app.api import api_router
3
  from app.core.config import settings
4
  from app.core.errors import error_handler
5
- from fastapi.middleware.cors import CORSMiddleware
6
 
7
  from app.utils import print_routes
8
  from app.utils.checks import run_checks
@@ -25,6 +26,12 @@ if settings.BACKEND_CORS_ORIGINS:
25
  allow_headers=["*"],
26
  )
27
 
 
 
 
 
 
 
28
  # Include routers
29
  app.include_router(api_router, prefix=settings.API_V1_STR)
30
 
 
1
  from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+
4
  from app.api import api_router
5
  from app.core.config import settings
6
  from app.core.errors import error_handler
 
7
 
8
  from app.utils import print_routes
9
  from app.utils.checks import run_checks
 
26
  allow_headers=["*"],
27
  )
28
 
29
+
30
+ @app.get("/ping")
31
+ async def ping():
32
+ return {"ping": "pong"}
33
+
34
+
35
  # Include routers
36
  app.include_router(api_router, prefix=settings.API_V1_STR)
37
 
app/tests/test_api/{__init__.py → test_ping.py} RENAMED
@@ -6,7 +6,7 @@ from app.main import app
6
  client = TestClient(app)
7
 
8
 
9
- def test_read_main():
10
- response = client.get("/")
11
  assert response.status_code == 200
12
- assert response.json() == {"msg": "Hello World"}
 
6
  client = TestClient(app)
7
 
8
 
9
+ def test_ping_main():
10
+ response = client.get("/ping")
11
  assert response.status_code == 200
12
+ assert response.json() == {"ping": "pong"}
app/tests/test_core/__init__.py DELETED
@@ -1,15 +0,0 @@
1
- from fastapi.testclient import TestClient
2
- from app.main import app
3
-
4
-
5
- def test_app():
6
- client = TestClient(app)
7
- response = client.get("/")
8
- assert response.status_code == 200
9
- assert response.json() == {"message": "Hello World"}
10
-
11
-
12
- def test_config():
13
- assert settings.app_name == "My FastAPI Project"
14
- assert settings.log_level == "debug"
15
- assert settings.max_connection_count == 10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/tests/test_core/test_server.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi.testclient import TestClient
2
+ from app.main import app
3
+ from app.core.config import settings
4
+
5
+ client = TestClient(app)
6
+
7
+
8
+ def test_ping_main():
9
+ response = client.get("/ping")
10
+ assert response.status_code == 200
11
+ assert response.json() == {"ping": "pong"}