@@ -33,10 +33,9 @@ class Settings(BaseSettings):
33
33
)
34
34
API_V1_STR : str = "/api/v1"
35
35
SECRET_KEY : str = secrets .token_urlsafe (32 )
36
- # 60 minutes * 24 hours * 8 days = 8 days
37
36
ACCESS_TOKEN_EXPIRE_MINUTES : int = 60 * 24 * 8
38
37
FRONTEND_HOST : str = "http://localhost:5173"
39
- ENVIRONMENT : Literal ["local" , "staging" , "production" ] = "local"
38
+ ENVIRONMENT : Literal ["local" , "staging" , "production" , "test" ] = "local"
40
39
41
40
BACKEND_CORS_ORIGINS : Annotated [
42
41
list [AnyUrl ] | str , BeforeValidator (parse_cors )
@@ -60,13 +59,17 @@ def all_cors_origins(self) -> list[str]:
60
59
@computed_field # type: ignore[prop-decorator]
61
60
@property
62
61
def SQLALCHEMY_DATABASE_URI (self ) -> PostgresDsn :
62
+ db_name = self .POSTGRES_DB
63
+ # Si el entorno es de test, usamos una base separada
64
+ if self .ENVIRONMENT == "test" :
65
+ db_name = f"{ self .POSTGRES_DB } _test"
63
66
return MultiHostUrl .build (
64
67
scheme = "postgresql+psycopg" ,
65
68
username = self .POSTGRES_USER ,
66
69
password = self .POSTGRES_PASSWORD ,
67
70
host = self .POSTGRES_SERVER ,
68
71
port = self .POSTGRES_PORT ,
69
- path = self . POSTGRES_DB ,
72
+ path = db_name ,
70
73
)
71
74
72
75
SMTP_TLS : bool = True
@@ -113,7 +116,6 @@ def _enforce_non_default_secrets(self) -> Self:
113
116
self ._check_default_secret (
114
117
"FIRST_SUPERUSER_PASSWORD" , self .FIRST_SUPERUSER_PASSWORD
115
118
)
116
-
117
119
return self
118
120
119
121
0 commit comments