Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ on:

jobs:
main:
uses: heyslava/workflows/.github/workflows/tox.yml@v0.3.0
uses: heyslava/workflows/.github/workflows/tox.yml@v1.3.0
with:
env: '["py311"]'
env: '["py313"]'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye
FROM python:3.13-slim-bullseye

WORKDIR /app

Expand Down
8 changes: 6 additions & 2 deletions bot/data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Base(DeclarativeBase):
metadata = meta


def _utc_now() -> dt.datetime:
return dt.datetime.now(dt.timezone.utc).replace(tzinfo=None)


class User(Base):
__tablename__ = 'users'
id: Mapped[int] = mapped_column(primary_key=True)
Expand Down Expand Up @@ -63,11 +67,11 @@ class Expense(Base):
comment: Mapped[str] = mapped_column(String, nullable=True)
cdate: Mapped[dt.datetime] = mapped_column(
DateTime,
default=dt.datetime.utcnow,
default=_utc_now,
)
cdate_tz: Mapped[dt.datetime] = mapped_column(
DateTime,
default=dt.datetime.utcnow,
default=_utc_now,
nullable=True,
)
is_replenishment: Mapped[bool] = mapped_column(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ aiogram==3.19.0
alembic
pydantic
pytz
SQLAlchemy==2.0.30
SQLAlchemy==2.0.51
16 changes: 11 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def engine():
tmpfile = Path(dir) / 'pytest.db'
conn_str = f'sqlite:///{tmpfile}'
engine = sa.create_engine(conn_str)
yield engine
try:
yield engine
finally:
engine.dispose()


@pytest.fixture(scope='function')
Expand All @@ -26,10 +29,13 @@ def db(engine):
session: orm.Session = _factory()
Base.metadata.create_all(bind=engine)

yield session
for table in reversed(Base.metadata.sorted_tables):
session.execute(table.delete())
session.commit()
try:
yield session
finally:
for table in reversed(Base.metadata.sorted_tables):
session.execute(table.delete())
session.commit()
session.close()


@pytest.fixture(scope='function')
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
env_list = py311,pre-commit
env_list = py313,pre-commit

[testenv]
deps =
Expand All @@ -17,6 +17,7 @@ commands =
addopts =
-ra
-v
-W error
testpaths =
tests
pythonpath = bot
Loading