Skip to content

Commit 062d573

Browse files
committed
finished tests for login and probably all tasks done
1 parent cd565f4 commit 062d573

23 files changed

+453
-388
lines changed
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
[flake8]
22
max-line-length = 88
3-
exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache
3+
select = C,E,F,W,B,B9
4+
ignore = E203, E501, W503
5+
exclude =
6+
__init__.py,
7+
.venv,
8+
__pycache__,
9+
.github,
10+
.vscode,
11+
config,
12+
locale,
13+
webhook
14+
app/tests/conftest.py

{{cookiecutter.project_name}}/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
# postgresql
55
data
66
data-debug
7+
tests_data
78

89
# Byte-compiled / optimized / DLL files
910
__pycache__/
1011
*.py[cod]
1112
*$py.class
13+
.env
1214

1315
# C extensions
1416
*.so

{{cookiecutter.project_name}}/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ RUN mkdir build
1313
WORKDIR /build
1414

1515
COPY ./app ./app
16-
COPY ./pytest.ini .
17-
COPY ./aerich.ini .
16+
COPY ./alembic.ini .
1817
COPY ./requirements.txt .
19-
COPY ./.env .
2018

2119
# We copy our app folder to the /build
2220

{{cookiecutter.project_name}}/alembic/versions/20211023121450_3c44f0828d4f_init.py

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

{{cookiecutter.project_name}}/alembic/versions/20211023022523_b6b74331d700_init.py renamed to {{cookiecutter.project_name}}/alembic/versions/20211023161504_e2318cba28d4_init.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""init
22
3-
Revision ID: b6b74331d700
3+
Revision ID: e2318cba28d4
44
Revises:
5-
Create Date: 2021-10-23 02:25:23.653930
5+
Create Date: 2021-10-23 16:15:04.828924
66
77
"""
88
from alembic import op
99
import sqlalchemy as sa
1010

1111

1212
# revision identifiers, used by Alembic.
13-
revision = 'b6b74331d700'
13+
revision = 'e2318cba28d4'
1414
down_revision = None
1515
branch_labels = None
1616
depends_on = None

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ async def login_access_token(
4646
@router.post("/test-token", response_model=schemas.User)
4747
async def test_token(current_user: User = Depends(deps.get_current_user)):
4848
"""
49-
Test access token
49+
Test access token for current user
5050
"""
5151
return current_user
5252

5353

5454
@router.post("/refresh-token", response_model=schemas.Token)
5555
async def refresh_token(
56-
refresh_token: str, session: AsyncSession = Depends(deps.get_session)
56+
input: schemas.TokenRefresh, session: AsyncSession = Depends(deps.get_session)
5757
):
5858
"""
5959
OAuth2 compatible token, get an access token for future requests using refresh token
6060
"""
6161
try:
6262
payload = jwt.decode(
63-
refresh_token, settings.SECRET_KEY, algorithms=[security.ALGORITHM]
63+
input.refresh_token, settings.SECRET_KEY, algorithms=[security.ALGORITHM]
6464
)
6565
token_data = schemas.TokenPayload(**payload)
6666
except (jwt.JWTError, ValidationError):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def update_user_me(
1717
current_user: models.User = Depends(deps.get_current_active_user),
1818
) -> Any:
1919
"""
20-
Update me.
20+
Update current user.
2121
"""
2222
if user_update.password is not None:
2323
current_user.hashed_password = get_password_hash(user_update.password)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from asyncio import get_event_loop
23
from typing import Optional
34

45
from sqlalchemy import select
@@ -7,7 +8,6 @@
78
from app.core.config import settings
89
from app.models import User
910
from app.session import async_session
10-
from asyncio import get_event_loop
1111

1212

1313
async def main() -> None:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .token import Token, TokenPayload
1+
from .token import Token, TokenPayload, TokenRefresh
22
from .user import User, UserCreate, UserUpdate

{{cookiecutter.project_name}}/app/schemas/token.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ class Token(BaseModel):
1515
class TokenPayload(BaseModel):
1616
sub: Optional[int] = None
1717
refresh: Optional[bool] = None
18+
19+
20+
class TokenRefresh(BaseModel):
21+
refresh_token: str

0 commit comments

Comments
 (0)