Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/config/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def get_settings() -> BaseAppSettings:
return Settings()


def get_jwt_auth_manager(settings: BaseAppSettings = Depends(get_settings)) -> JWTAuthManagerInterface:
def get_jwt_auth_manager(
settings: BaseAppSettings = Depends(get_settings),
) -> JWTAuthManagerInterface:
return JWTAuthManager(
secret_key_access=settings.SECRET_KEY_ACCESS,
secret_key_refresh=settings.SECRET_KEY_REFRESH,
algorithm=settings.JWT_SIGNING_ALGORITHM
algorithm=settings.JWT_SIGNING_ALGORITHM,
)
10 changes: 6 additions & 4 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
class BaseAppSettings(BaseSettings):
BASE_DIR: Path = Path(__file__).parent.parent
PATH_TO_DB: str = str(BASE_DIR / "database" / "source" / "theater.db")
PATH_TO_MOVIES_CSV: str = str(BASE_DIR / "database" / "seed_data" / "imdb_movies.csv")
PATH_TO_MOVIES_CSV: str = str(
BASE_DIR / "database" / "seed_data" / "imdb_movies.csv"
)
LOGIN_TIME_DAYS: int = 7


Expand All @@ -30,9 +32,9 @@ class TestingSettings(BaseAppSettings):
JWT_SIGNING_ALGORITHM: str = "HS256"

def model_post_init(self, __context: dict[str, Any] | None = None) -> None:
object.__setattr__(self, 'PATH_TO_DB', ":memory:")
object.__setattr__(self, "PATH_TO_DB", ":memory:")
object.__setattr__(
self,
'PATH_TO_MOVIES_CSV',
str(self.BASE_DIR / "database" / "seed_data" / "test_data.csv")
"PATH_TO_MOVIES_CSV",
str(self.BASE_DIR / "database" / "seed_data" / "test_data.csv"),
)
8 changes: 4 additions & 4 deletions src/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
UserGroupEnum,
ActivationTokenModel,
PasswordResetTokenModel,
RefreshTokenModel
RefreshTokenModel,
)
from database.models.movies import (
MovieModel,
Expand All @@ -17,7 +17,7 @@
CountryModel,
MoviesGenresModel,
ActorsMoviesModel,
MoviesLanguagesModel
MoviesLanguagesModel,
)
from database.session_sqlite import reset_sqlite_database as reset_database
from database.validators import accounts as accounts_validators
Expand All @@ -27,10 +27,10 @@
if environment == "testing":
from database.session_sqlite import (
get_sqlite_db_contextmanager as get_db_contextmanager,
get_sqlite_db as get_db
get_sqlite_db as get_db,
)
else:
from database.session_postgresql import (
get_postgresql_db_contextmanager as get_db_contextmanager,
get_postgresql_db as get_db
get_postgresql_db as get_db,
)
6 changes: 3 additions & 3 deletions src/database/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from alembic import context

from database.models import movies, accounts # noqa: F401
from database.models import movies, accounts # noqa: F401
from database.models.base import Base
from database.session_postgresql import postgresql_engine

Expand Down Expand Up @@ -47,7 +47,7 @@ def run_migrations_offline() -> None:
connection=connection,
target_metadata=target_metadata,
compare_type=True,
compare_server_default=True
compare_server_default=True,
)

with context.begin_transaction():
Expand All @@ -68,7 +68,7 @@ def run_migrations_online() -> None:
connection=connection,
target_metadata=target_metadata,
compare_type=True,
compare_server_default=True
compare_server_default=True,
)

with context.begin_transaction():
Expand Down
71 changes: 45 additions & 26 deletions src/database/migrations/versions/2da0dc469be8_temp_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,67 @@
Create Date: 2025-01-07 21:36:44.563306

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '2da0dc469be8'
down_revision: Union[str, None] = '32b1054a69e3'
revision: str = "2da0dc469be8"
down_revision: Union[str, None] = "32b1054a69e3"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('activation_tokens', 'token',
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False)
op.alter_column('password_reset_tokens', 'token',
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False)
op.alter_column('refresh_tokens', 'token',
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False)
op.alter_column(
"activation_tokens",
"token",
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False,
)
op.alter_column(
"password_reset_tokens",
"token",
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False,
)
op.alter_column(
"refresh_tokens",
"token",
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=64),
existing_nullable=False,
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('refresh_tokens', 'token',
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False)
op.alter_column('password_reset_tokens', 'token',
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False)
op.alter_column('activation_tokens', 'token',
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False)
op.alter_column(
"refresh_tokens",
"token",
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False,
)
op.alter_column(
"password_reset_tokens",
"token",
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False,
)
op.alter_column(
"activation_tokens",
"token",
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=255),
existing_nullable=False,
)
# ### end Alembic commands ###
Loading
Loading