Commit 95eff823 authored by Nicolas Schmid's avatar Nicolas Schmid
Browse files

feat: update tests to db and remove project well/catalog

parent 961801e7
Pipeline #2298 passed with stage
in 2 minutes and 46 seconds
......@@ -98,13 +98,10 @@ def get_seismic_catalog(db: Session, parent_id: int,
def get_hydraulic_well(db: Session, parent_id: int,
parent_type: Literal['project', 'forecast', 'scenario']
parent_type: Literal['forecast', 'scenario']
) -> Optional[InjectionWell]:
statement_base = select(InjectionWell)
if parent_type == 'project':
statement = statement_base.filter(
InjectionWell.project_id == parent_id)
elif parent_type == 'forecast':
if parent_type == 'forecast':
statement = statement_base.filter(
InjectionWell.forecast_id == parent_id)
elif parent_type == 'scenario':
......
......@@ -3,8 +3,7 @@ from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from typing import List, Optional
from ramsis_fastapi.schemas import ForecastSchema, InjectionWellSchema, \
ProjectSchema, SeismicCatalogSchema
from ramsis_fastapi.schemas import ForecastSchema, ProjectSchema
from ramsis_fastapi import crud
from ramsis_fastapi.dependencies import get_db
......@@ -51,34 +50,3 @@ async def read_project_forecasts(project_id: int,
if not db_result:
raise HTTPException(status_code=404, detail="No forecasts found.")
return db_result
@router.get("/{project_id}/catalog",
response_model=SeismicCatalogSchema,
response_model_exclude_none=True)
async def read_project_catalog(project_id: int,
db: Session = Depends(get_db)):
"""
Returns a catalog associated with a project.
"""
db_result = crud.get_seismic_catalog(db, parent_id=project_id,
parent_type='project')
if not db_result:
raise HTTPException(status_code=404, detail="Catalog "
"not found")
return db_result
@router.get("/{project_id}/well",
response_model=InjectionWellSchema,
response_model_exclude_none=True)
async def read_project_well(project_id: int, db: Session = Depends(get_db)):
"""
Returns a hydraulic well associated with a project.
"""
db_result = crud.get_hydraulic_well(db, parent_id=project_id,
parent_type='project')
if not db_result:
raise HTTPException(status_code=404, detail="Well "
"not found")
return db_result
......@@ -10,20 +10,20 @@ def test_read_forecasts():
def test_read_forecast():
response = client.get("/v1/forecast/1")
response = client.get("/v1/forecast/46")
assert response.status_code == 200
def test_read_forecast_scenarios():
response = client.get("/v1/forecast/1/scenario")
response = client.get("/v1/forecast/46/scenario")
assert response.status_code == 200
def test_read_forecast_catalog():
response = client.get("/v1/forecast/1/catalog")
response = client.get("/v1/forecast/46/catalog")
assert response.status_code == 200
def test_read_forecast_well():
response = client.get("/v1/forecast/1/well")
response = client.get("/v1/forecast/46/well")
assert response.status_code == 200
......@@ -5,5 +5,5 @@ client = TestClient(app)
def test_read_model_run():
response = client.get("/v1/seismicitymodelrun/1")
response = client.get("/v1/seismicitymodelrun/90")
assert response.status_code == 200
......@@ -10,20 +10,10 @@ def test_read_projects():
def test_read_project():
response = client.get("/v1/project/1")
response = client.get("/v1/project/4")
assert response.status_code == 200
def test_read_project_forecasts():
response = client.get("/v1/project/1/forecast")
assert response.status_code == 200
def test_read_project_catalog():
response = client.get("/v1/project/1/catalog")
assert response.status_code == 200
def test_read_project_well():
response = client.get("/v1/project/1/well")
response = client.get("/v1/project/4/forecast")
assert response.status_code == 200
......@@ -10,10 +10,10 @@ def test_read_scenarios():
def test_read_scenario():
response = client.get("/v1/scenario/1")
response = client.get("/v1/scenario/46")
assert response.status_code == 200
def test_read_scenario_injectionplan():
response = client.get("/v1/scenario/1/injectionplan")
response = client.get("/v1/scenario/46/injectionplan")
assert response.status_code == 200
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment