Spaces:
Running
Running
sghorbal
commited on
Commit
·
8b2303c
1
Parent(s):
236e5a4
fix for api tests
Browse files- src/main.py +1 -0
- tests/conftest.py +3 -2
src/main.py
CHANGED
|
@@ -304,6 +304,7 @@ async def ingest_matches(year: Optional[int] = None):
|
|
| 304 |
"""
|
| 305 |
job = schedule_matches_ingestion(year=year)
|
| 306 |
|
|
|
|
| 307 |
return {"job_id": job.get_id(), "job_status": job.get_status()}
|
| 308 |
|
| 309 |
@app.post("/batch/match/insert", tags=["match"], description="Insert a batch of matches into the database")
|
|
|
|
| 304 |
"""
|
| 305 |
job = schedule_matches_ingestion(year=year)
|
| 306 |
|
| 307 |
+
|
| 308 |
return {"job_id": job.get_id(), "job_status": job.get_status()}
|
| 309 |
|
| 310 |
@app.post("/batch/match/insert", tags=["match"], description="Insert a batch of matches into the database")
|
tests/conftest.py
CHANGED
|
@@ -9,7 +9,7 @@ from sqlalchemy import create_engine, text
|
|
| 9 |
from sqlalchemy.orm import sessionmaker
|
| 10 |
from responses.matchers import json_params_matcher
|
| 11 |
from fastapi.testclient import TestClient
|
| 12 |
-
from src.main import app
|
| 13 |
from src.repository.common import get_session
|
| 14 |
|
| 15 |
from src.entity import Base
|
|
@@ -32,9 +32,10 @@ def client(db_session):
|
|
| 32 |
# Override the get_session dependency to use the test database session
|
| 33 |
def override_get_session():
|
| 34 |
yield db_session
|
| 35 |
-
|
| 36 |
# Override the dependency in the FastAPI app
|
| 37 |
app.dependency_overrides[get_session] = override_get_session
|
|
|
|
| 38 |
|
| 39 |
return TestClient(app)
|
| 40 |
|
|
|
|
| 9 |
from sqlalchemy.orm import sessionmaker
|
| 10 |
from responses.matchers import json_params_matcher
|
| 11 |
from fastapi.testclient import TestClient
|
| 12 |
+
from src.main import app, provide_connection
|
| 13 |
from src.repository.common import get_session
|
| 14 |
|
| 15 |
from src.entity import Base
|
|
|
|
| 32 |
# Override the get_session dependency to use the test database session
|
| 33 |
def override_get_session():
|
| 34 |
yield db_session
|
| 35 |
+
|
| 36 |
# Override the dependency in the FastAPI app
|
| 37 |
app.dependency_overrides[get_session] = override_get_session
|
| 38 |
+
app.dependency_overrides[provide_connection] = override_get_session
|
| 39 |
|
| 40 |
return TestClient(app)
|
| 41 |
|