Skip to content

improved coverage to 91 #12

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

Merged
merged 1 commit into from
Jun 16, 2024
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
6 changes: 3 additions & 3 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
coverage:
precision: 2
round: up
range: 85...100
range: 90...100
status:
patch:
default:
target: 85%
target: 90%
project:
default:
target: 85%
target: 90%
7 changes: 5 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ commands =

commands =
poetry install --with dev
poetry run coverage run --source=. -m pytest
poetry run coverage report -m --fail-under=85
poetry run coverage run --source=. --omit=tracker/main.py -m pytest
poetry run coverage report -m --fail-under=90

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

[testenv:runserver]
commands = poetry run fastapi dev tracker/main.py

; [testenv:docs-win32]

; passenv = *
Expand Down
8 changes: 5 additions & 3 deletions tracker/db/session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import AsyncGenerator

from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import declarative_base

Expand All @@ -12,6 +14,6 @@
BaseModel = declarative_base()


async def get_db():
async with Session() as db:
yield db
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with Session() as session:
yield session
15 changes: 6 additions & 9 deletions tracker/models/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from sqlalchemy import TIMESTAMP, Column, Integer
from sqlalchemy.orm import Mapped
from sqlalchemy import Column, DateTime, Integer
from sqlalchemy.sql import func

from tracker.db.session import BaseModel
Expand All @@ -8,13 +7,11 @@
class Base(BaseModel):
__abstract__ = True

id: Mapped[int] = Column(Integer, primary_key=True, autoincrement=True, index=True)
created_at: Mapped[TIMESTAMP] = Column(
TIMESTAMP, server_default=func.now(), index=True
)
updated_at: Mapped[TIMESTAMP] = Column(
TIMESTAMP,
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)
updated_at = Column(
DateTime(timezone=True),
server_default=func.now(),
server_onupdate=func.current_timestamp(),
onupdate=func.current_timestamp(),
index=True,
)
2 changes: 1 addition & 1 deletion tracker/services/bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def bug_by_id(db: AsyncSession, id: int) -> BugOutput | HTTPException:
def bug_output(bug: Bug) -> BugOutput:
story = jsonable_encoder(obj=bug.story)
bug_output = BugOutput(
id=bug.id,
id=int(bug.id),
title=bug.title,
description=bug.description,
story=story,
Expand Down
3 changes: 2 additions & 1 deletion tracker/services/story.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from http import HTTPStatus
from typing import Sequence

from fastapi import HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
Expand All @@ -10,7 +11,7 @@

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

return query.scalars().all()
Expand Down
Loading