Skip to content

Commit 0ad3e67

Browse files
committed
fix tests, prepare version support
1 parent 200d31a commit 0ad3e67

File tree

15 files changed

+56
-45
lines changed

15 files changed

+56
-45
lines changed
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
DEBUG=true
2-
SECRET_KEY=string
3-
ACCESS_TOKEN_EXPIRE_MINUTES=11520
4-
REFRESH_TOKEN_EXPIRE_MINUTES=40320
1+
SECRET_KEY="DVnFmhwvjEhJZpuhndxjhlezxQPJmBIIkMDEmFREWQADPcUnrG"
2+
ENVIRONMENT="DEV"
3+
ACCESS_TOKEN_EXPIRE_MINUTES="11520"
4+
REFRESH_TOKEN_EXPIRE_MINUTES="40320"
5+
BACKEND_CORS_ORIGINS="http://localhost:3000,http://localhost:8001"
56

6-
BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:8001
7+
DEFAULT_DATABASE_HOSTNAME="localhost"
8+
DEFAULT_DATABASE_USER="rDGJeEDqAz"
9+
DEFAULT_DATABASE_PASSWORD="XsPQhCoEfOQZueDjsILetLDUvbvSxAMnrVtgVZpmdcSssUgbvs"
10+
DEFAULT_DATABASE_PORT="5387"
11+
DEFAULT_DATABASE_DB="default_db"
712

8-
DEFAULT_DATABASE_USER=postgres
9-
DEFAULT_DATABASE_PASSWORD=strong_password
10-
POSTGRES_SERVER=db
11-
DEFAULT_DATABASE_DB=db
12-
DEFAULT_DATABASE_PORT=4999
13+
TEST_DATABASE_HOSTNAME="localhost"
14+
TEST_DATABASE_USER="test"
15+
TEST_DATABASE_PASSWORD="ywRCUjJijmQoBmWxIfLldOoITPzajPSNvTvHyugQoSqGwNcvQE"
16+
TEST_DATABASE_PORT="37270"
17+
TEST_DATABASE_DB="test_db"
1318

14-
FIRST_SUPERUSER_EMAIL=example@example.com
15-
FIRST_SUPERUSER_PASSWORD=string_password
19+
FIRST_SUPERUSER_EMAIL="example@example.com"
20+
FIRST_SUPERUSER_PASSWORD="OdLknKQJMUwuhpAVHvRC"

{{cookiecutter.project_name}}/.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ TEST_DATABASE_PASSWORD="{{ random_ascii_string(50) }}"
1616
TEST_DATABASE_PORT="{{ range(30000, 40000) | random }}"
1717
TEST_DATABASE_DB="test_db"
1818

19-
FIRST_SUPERUSER_EMAIL=example@example.com
19+
FIRST_SUPERUSER_EMAIL="example@example.com"
2020
FIRST_SUPERUSER_PASSWORD="{{ random_ascii_string(20) }}"

{{cookiecutter.project_name}}/.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# vscode
2-
.vscode
31

42
# postgresql
53
data
6-
data-debug
7-
tests_data
4+
default_database_data
5+
test_database_data
86

97
# Byte-compiled / optimized / DLL files
108
__pycache__/
@@ -14,7 +12,6 @@ __pycache__/
1412

1513
# C extensions
1614
*.so
17-
.env
1815

1916
# Distribution / packaging
2017
.Python

{{cookiecutter.project_name}}/app/api/api.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

{{cookiecutter.project_name}}/app/api/endpoints/__init__.py renamed to {{cookiecutter.project_name}}/app/api/api_v1/__init__.py

File renamed without changes.

{{cookiecutter.project_name}}/app/api/endpoints/auth.py renamed to {{cookiecutter.project_name}}/app/api/api_v1/auth.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
from sqlalchemy.ext.asyncio import AsyncSession
99

1010
from app import schemas
11-
from app.api import deps
11+
from app.api.routers import api_v1_router
12+
from app.api.api_v1 import deps
1213
from app.core import security
1314
from app.core.config import settings
1415
from app.models import User
1516

17+
1618
router = APIRouter()
1719

1820

@@ -88,3 +90,6 @@ async def refresh_token(
8890
"refresh_token": refresh_token,
8991
"refresh_expire_at": refresh_expire_at,
9092
}
93+
94+
95+
api_v1_router.include_router(router, prefix="", tags=["users"])

{{cookiecutter.project_name}}/app/api/deps.py renamed to {{cookiecutter.project_name}}/app/api/api_v1/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from app.models import User
1414
from app.session import async_session
1515

16-
reusable_oauth2 = OAuth2PasswordBearer(tokenUrl="/auth/access-token")
16+
reusable_oauth2 = OAuth2PasswordBearer(tokenUrl="v1/auth/access-token")
1717

1818

1919
async def get_session() -> AsyncGenerator[AsyncSession, None]:

{{cookiecutter.project_name}}/app/api/endpoints/users.py renamed to {{cookiecutter.project_name}}/app/api/api_v1/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sqlalchemy.ext.asyncio import AsyncSession
55

66
from app import models, schemas
7-
from app.api import deps
7+
from app.api.api_v1 import deps
88
from app.core.security import get_password_hash
99

1010
router = APIRouter()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from fastapi import APIRouter
2+
3+
4+
api_v1_router = APIRouter()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os
2+
3+
# We overwrite variables from .env to hardcoded one to connect with test database
4+
# We don't want to mess up dev database
5+
#
6+
# Put here any pytest-specific code (it will run before app/tests/...)
7+
8+
os.environ["ENVIRONMENT"] = "PYTEST"

0 commit comments

Comments
 (0)