mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
✨ Use Pydantic BaseSettings for config settings (#87)
* Use Pydantic BaseSettings for config settings * Update fastapi dep to >=0.47.0 and email_validator to email-validator * Fix deprecation warning for Pydantic >=1.0 * Properly support old-format comma separated strings for BACKEND_CORS_ORIGINS Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import requests
|
||||
|
||||
from app import crud
|
||||
from app.core import config
|
||||
from app.core.config import settings
|
||||
from app.db.session import db_session
|
||||
from app.schemas.user import UserCreate, UserUpdate
|
||||
from app.tests.utils.utils import get_server_api, random_lower_string, random_email
|
||||
@@ -10,7 +10,7 @@ from app.tests.utils.utils import get_server_api, random_lower_string, random_em
|
||||
def user_authentication_headers(server_api, email, password):
|
||||
data = {"username": email, "password": password}
|
||||
|
||||
r = requests.post(f"{server_api}{config.API_V1_STR}/login/access-token", data=data)
|
||||
r = requests.post(f"{server_api}{settings.API_V1_STR}/login/access-token", data=data)
|
||||
response = r.json()
|
||||
auth_token = response["access_token"]
|
||||
headers = {"Authorization": f"Bearer {auth_token}"}
|
||||
|
||||
@@ -2,7 +2,8 @@ import random
|
||||
import string
|
||||
|
||||
import requests
|
||||
from app.core import config
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def random_lower_string():
|
||||
@@ -14,18 +15,18 @@ def random_email():
|
||||
|
||||
|
||||
def get_server_api():
|
||||
server_name = f"http://{config.SERVER_NAME}"
|
||||
server_name = f"http://{settings.SERVER_NAME}"
|
||||
return server_name
|
||||
|
||||
|
||||
def get_superuser_token_headers():
|
||||
server_api = get_server_api()
|
||||
login_data = {
|
||||
"username": config.FIRST_SUPERUSER,
|
||||
"password": config.FIRST_SUPERUSER_PASSWORD,
|
||||
"username": settings.FIRST_SUPERUSER,
|
||||
"password": settings.FIRST_SUPERUSER_PASSWORD,
|
||||
}
|
||||
r = requests.post(
|
||||
f"{server_api}{config.API_V1_STR}/login/access-token", data=login_data
|
||||
f"{server_api}{settings.API_V1_STR}/login/access-token", data=login_data
|
||||
)
|
||||
tokens = r.json()
|
||||
a_token = tokens["access_token"]
|
||||
|
||||
Reference in New Issue
Block a user