Compare commits
No commits in common. "6c46a1df3a060e3dac1f00245aa299fdc9a12d5e" and "04440e62700a00619a122f39837a61b96452f638" have entirely different histories.
6c46a1df3a
...
04440e6270
9 changed files with 3 additions and 82 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
[pytest]
|
|
||||||
testpaths = src
|
|
||||||
python_files = *_test.py
|
|
||||||
addopts = -ra -q
|
|
||||||
3
setup.py
3
setup.py
|
|
@ -6,8 +6,5 @@ setup(
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
package_data={'src': ['templates/**/*.html', 'templates/**/*.txt']},
|
package_data={'src': ['templates/**/*.html', 'templates/**/*.txt']},
|
||||||
exclude_package_data={
|
|
||||||
'': ['*_test.py'],
|
|
||||||
},
|
|
||||||
scripts=['./src/main.py'],
|
scripts=['./src/main.py'],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ mkShell {
|
||||||
python313Packages.ruff
|
python313Packages.ruff
|
||||||
python313Packages.python-lsp-server
|
python313Packages.python-lsp-server
|
||||||
python313Packages.jedi-language-server
|
python313Packages.jedi-language-server
|
||||||
python313Packages.pytest
|
|
||||||
ty
|
ty
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
from .db import Base, CRUD, CRUDRepo, UpdateMissingEntryError, get_database
|
|
||||||
from .users import UserModel, UserRepoImpl
|
|
||||||
from .publication import (
|
|
||||||
PublicationEntryModel,
|
|
||||||
PublicationSequenceModel,
|
|
||||||
PublicationOrderModel,
|
|
||||||
PublicationModel,
|
|
||||||
PublicationRepoImpl,
|
|
||||||
)
|
|
||||||
from .subscription import SubscriptionModel, SubscriptionRepoImpl
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
'Base',
|
|
||||||
'CRUD',
|
|
||||||
'CRUDRepo',
|
|
||||||
'UpdateMissingEntryError',
|
|
||||||
'get_database',
|
|
||||||
'UserModel',
|
|
||||||
'UserRepoImpl',
|
|
||||||
'PublicationEntryModel',
|
|
||||||
'PublicationSequenceModel',
|
|
||||||
'PublicationOrderModel',
|
|
||||||
'PublicationModel',
|
|
||||||
'PublicationRepoImpl',
|
|
||||||
'SubscriptionModel',
|
|
||||||
'SubscriptionRepoImpl',
|
|
||||||
]
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
from src.infra import Base
|
|
||||||
from sqlalchemy import Engine, create_engine
|
|
||||||
|
|
||||||
|
|
||||||
def mock_db() -> Engine:
|
|
||||||
engine = create_engine('sqlite:///:memory:', echo=True)
|
|
||||||
Base.metadata.create_all(engine)
|
|
||||||
return engine
|
|
||||||
|
|
@ -18,7 +18,7 @@ class UserModel(Base):
|
||||||
__tablename__ = 'user'
|
__tablename__ = 'user'
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
email: Mapped[str] = mapped_column(String(254), unique=True)
|
email: Mapped[str] = mapped_column(String(254), unique=True)
|
||||||
email_confirmed: Mapped[bool] = mapped_column(default=False)
|
email_confirmed: Mapped[bool] = mapped_column()
|
||||||
password_hash: Mapped[str] = mapped_column(VARCHAR(255))
|
password_hash: Mapped[str] = mapped_column(VARCHAR(255))
|
||||||
|
|
||||||
subscriptions: Mapped[list['SubscriptionModel']] = relationship(back_populates='user')
|
subscriptions: Mapped[list['SubscriptionModel']] = relationship(back_populates='user')
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
from src.utils.secret import SecretBox
|
|
||||||
from src.services.users.data import UserDTO, User
|
|
||||||
from src.services.users.repo import UserRepo
|
|
||||||
from src.infra.users import UserRepoImpl
|
|
||||||
from src.infra.db_test import mock_db
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
DB = mock_db()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def db():
|
|
||||||
return DB
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def repo(db):
|
|
||||||
return UserRepoImpl(db)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def users(repo: UserRepo):
|
|
||||||
return [
|
|
||||||
repo.create(UserDTO('example@example.com', SecretBox('hunter1')), None),
|
|
||||||
repo.create(UserDTO('example2@example.com', SecretBox('hunter2')), None),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_getting_a_user_by_email(users: list[User], repo: UserRepo):
|
|
||||||
assert repo.get_user_by_email('example@example.com') == users[0]
|
|
||||||
assert repo.get_user_by_email('fred@example.com') is None
|
|
||||||
|
|
@ -6,7 +6,8 @@ from src.services.email import EmailService, get_email_service
|
||||||
from src.services.auth import AuthService
|
from src.services.auth import AuthService
|
||||||
from src.services.users.service import UserService
|
from src.services.users.service import UserService
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from src.infra import get_database, UserRepoImpl
|
from src.infra.db import get_database
|
||||||
|
from src.infra.users import UserRepoImpl
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
import argparse
|
import argparse
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,6 @@ class SecretBox[T]:
|
||||||
def expose_secret(self) -> T:
|
def expose_secret(self) -> T:
|
||||||
return self._item
|
return self._item
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
if not isinstance(other, SecretBox):
|
|
||||||
return False
|
|
||||||
|
|
||||||
return self._item == other._item
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '<SECRET>'
|
return '<SECRET>'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue