Skip to content

Commit 4923c1e

Browse files
committed
feat: refactor app initialization to import from main module
1 parent 9c74fac commit 4923c1e

5 files changed

Lines changed: 4 additions & 30 deletions

File tree

core/app.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
)
2525
from fastapi.openapi.utils import get_openapi
2626

27-
from .initializers import (
28-
register_routes,
29-
erase_and_rebuild_db,
30-
)
3127
from .settings import settings
3228

3329

@@ -41,7 +37,6 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
4137

4238
seed_all(10, skip_if_exists=True)
4339

44-
register_routes(app)
4540
yield
4641

4742

tests/__init__.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,10 @@
2828
os.environ["POSTGRES_DB"] = "ocotilloapi_test"
2929

3030
from fastapi.testclient import TestClient
31-
from fastapi_pagination import add_pagination
32-
from starlette.middleware.cors import CORSMiddleware
3331

34-
from core.initializers import register_routes
3532
from db import Parameter, Base
3633
from db.engine import session_ctx
37-
from core.app import app
38-
39-
register_routes(app)
40-
41-
app.add_middleware(
42-
CORSMiddleware,
43-
allow_origins=["*"], # Allows all origins, adjust as needed for security
44-
allow_credentials=True,
45-
allow_methods=["*"],
46-
allow_headers=["*"],
47-
)
48-
49-
add_pagination(app)
34+
from main import app
5035

5136
client = TestClient(app)
5237

tests/features/steps/api_common.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
admin_function,
2222
amp_admin_function,
2323
)
24-
from core.initializers import register_routes
2524
from starlette.testclient import TestClient
2625

2726

@@ -31,9 +30,7 @@ def step_given_api_is_running(context):
3130
Ensures the API app is initialized and client is ready.
3231
Behave will keep 'context' across steps, allowing us to reuse response data.
3332
"""
34-
from core.app import app
35-
36-
register_routes(app)
33+
from main import app
3734

3835
def override_authentication(default=True):
3936
"""

tests/features/steps/cli_common.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
admin_function,
2424
amp_admin_function,
2525
)
26-
from core.initializers import register_routes
2726

2827

2928
@given("a functioning cli")
@@ -32,9 +31,7 @@ def step_given_cli_is_running(context):
3231
Initializes app/auth context needed by CLI-backed feature tests
3332
that still perform DB-backed assertions.
3433
"""
35-
from core.app import app
36-
37-
register_routes(app)
34+
from main import app
3835

3936
def override_authentication(default=True):
4037
def closure():

tests/test_asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pytest
2020

2121
from api.asset import get_storage_bucket
22-
from core.app import app
22+
from main import app
2323
from core.dependencies import viewer_function, admin_function, editor_function
2424
from db import Asset
2525
from schemas import DT_FMT

0 commit comments

Comments
 (0)