diff --git a/src/cartsnitch_api/config.py b/src/cartsnitch_api/config.py index c835bca..c71d753 100644 --- a/src/cartsnitch_api/config.py +++ b/src/cartsnitch_api/config.py @@ -23,7 +23,12 @@ class Settings(BaseSettings): auth_service_url: str = "http://auth:3001" - cors_origins: list[str] = ["http://localhost:3000", "https://cartsnitch.com"] + cors_origins: list[str] = [ + "http://localhost:3000", + "https://cartsnitch.com", + "https://dev.cartsnitch.com", + "https://uat.cartsnitch.com", + ] receiptwitness_url: str = "http://receiptwitness:8001" stickershock_url: str = "http://stickershock:8002" diff --git a/src/cartsnitch_api/main.py b/src/cartsnitch_api/main.py index 9993b29..bd5a569 100644 --- a/src/cartsnitch_api/main.py +++ b/src/cartsnitch_api/main.py @@ -6,7 +6,6 @@ from fastapi import APIRouter, FastAPI from cartsnitch_api.auth.routes import router as auth_router from cartsnitch_api.cache import cache_client -from cartsnitch_api.database import dispose_engine from cartsnitch_api.middleware.cors import add_cors_middleware from cartsnitch_api.middleware.error_handler import add_error_handlers, add_error_monitor_middleware from cartsnitch_api.middleware.rate_limit import add_rate_limit_middleware @@ -26,6 +25,7 @@ from cartsnitch_api.routes.user import router as user_router @asynccontextmanager async def lifespan(app: FastAPI): + from cartsnitch_api.database import dispose_engine await cache_client.initialize() yield await cache_client.close() diff --git a/tests/conftest.py b/tests/conftest.py index b684a41..9908d35 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -177,8 +177,10 @@ async def _create_test_user_and_session( async with db_engine.begin() as conn: await conn.execute( text( - "INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) " - "VALUES (:id, :email, :hashed_password, :display_name, :email_verified, :created_at, :updated_at)" + "INSERT INTO users (id, email, hashed_password, display_name, " + "email_verified, created_at, updated_at) " + "VALUES (:id, :email, :hashed_password, :display_name, :email_verified, " + ":created_at, :updated_at)" ), { "id": user_id, diff --git a/tests/test_auth/test_auth_endpoints.py b/tests/test_auth/test_auth_endpoints.py index 9b55a4c..c2ed7c2 100644 --- a/tests/test_auth/test_auth_endpoints.py +++ b/tests/test_auth/test_auth_endpoints.py @@ -138,7 +138,8 @@ async def test_expired_session_rejected(client, db_engine): async with db_engine.begin() as conn: await conn.execute( text( - "INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) " + "INSERT INTO users (id, email, hashed_password, display_name, " + "email_verified, created_at, updated_at) " "VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)" ), { diff --git a/tests/test_config.py b/tests/test_config.py index f594bc2..2f94ec9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,5 @@ """Tests for Settings config, specifically the database_url env var fallback.""" -import os - from cartsnitch_api.config import Settings diff --git a/tests/test_e2e/test_auth_validation.py b/tests/test_e2e/test_auth_validation.py index f0e38cd..a4db942 100644 --- a/tests/test_e2e/test_auth_validation.py +++ b/tests/test_e2e/test_auth_validation.py @@ -65,7 +65,8 @@ class TestSessionValidation: async with db_engine.begin() as conn: await conn.execute( text( - "INSERT INTO users (id, email, hashed_password, display_name, email_verified, created_at, updated_at) " + "INSERT INTO users (id, email, hashed_password, display_name, " + "email_verified, created_at, updated_at) " "VALUES (:id, :email, :hp, :dn, :ev, :ca, :ua)" ), { diff --git a/tests/test_middleware/test_rate_limit.py b/tests/test_middleware/test_rate_limit.py index fbfe7d1..3a0e5a9 100644 --- a/tests/test_middleware/test_rate_limit.py +++ b/tests/test_middleware/test_rate_limit.py @@ -1,7 +1,7 @@ """Tests for rate limiting middleware.""" import time -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import AsyncMock, MagicMock import pytest