Skip to content

Commit 54821f9

Browse files
committed
improved coverage to 91
1 parent 0c9876b commit 54821f9

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

codecov.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
coverage:
22
precision: 2
33
round: up
4-
range: 85...100
4+
range: 90...100
55
status:
66
patch:
77
default:
8-
target: 85%
8+
target: 90%
99
project:
1010
default:
11-
target: 85%
11+
target: 90%

tox.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ commands =
2626

2727
commands =
2828
poetry install --with dev
29-
poetry run coverage run --source=. -m pytest
30-
poetry run coverage report -m --fail-under=85
29+
poetry run coverage run --source=. --omit=tracker/main.py -m pytest
30+
poetry run coverage report -m --fail-under=90
3131

3232
[testenv:coverage]
3333
commands = poetry run coverage xml -o coverage.xml
3434

35+
[testenv:runserver]
36+
commands = poetry run fastapi dev tracker/main.py
37+
3538
; [testenv:docs-win32]
3639

3740
; passenv = *

tracker/db/session.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import AsyncGenerator
2+
13
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
24
from sqlalchemy.orm import declarative_base
35

@@ -12,6 +14,6 @@
1214
BaseModel = declarative_base()
1315

1416

15-
async def get_db():
16-
async with Session() as db:
17-
yield db
17+
async def get_db() -> AsyncGenerator[AsyncSession, None]:
18+
async with Session() as session:
19+
yield session

tracker/models/base.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from sqlalchemy import TIMESTAMP, Column, Integer
2-
from sqlalchemy.orm import Mapped
1+
from sqlalchemy import Column, DateTime, Integer
32
from sqlalchemy.sql import func
43

54
from tracker.db.session import BaseModel
@@ -8,13 +7,11 @@
87
class Base(BaseModel):
98
__abstract__ = True
109

11-
id: Mapped[int] = Column(Integer, primary_key=True, autoincrement=True, index=True)
12-
created_at: Mapped[TIMESTAMP] = Column(
13-
TIMESTAMP, server_default=func.now(), index=True
14-
)
15-
updated_at: Mapped[TIMESTAMP] = Column(
16-
TIMESTAMP,
10+
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
11+
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)
12+
updated_at = Column(
13+
DateTime(timezone=True),
1714
server_default=func.now(),
18-
server_onupdate=func.current_timestamp(),
15+
onupdate=func.current_timestamp(),
1916
index=True,
2017
)

tracker/services/bug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def bug_by_id(db: AsyncSession, id: int) -> BugOutput | HTTPException:
2323
def bug_output(bug: Bug) -> BugOutput:
2424
story = jsonable_encoder(obj=bug.story)
2525
bug_output = BugOutput(
26-
id=bug.id,
26+
id=int(bug.id),
2727
title=bug.title,
2828
description=bug.description,
2929
story=story,

tracker/services/story.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from http import HTTPStatus
2+
from typing import Sequence
23

34
from fastapi import HTTPException
45
from sqlalchemy.ext.asyncio import AsyncSession
@@ -10,7 +11,7 @@
1011

1112
async def stories(
1213
db: AsyncSession, skip: int = 0, limit: int = 10
13-
) -> list[StoryOutput]:
14+
) -> Sequence[StoryOutput]:
1415
query = await db.execute(select(Story).offset(skip).limit(limit=limit))
1516

1617
return query.scalars().all()

0 commit comments

Comments
 (0)