Skip to content

Commit

Permalink
테스트 커버리지 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
riroan committed Aug 24, 2024
1 parent ae2f82b commit c690c7d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 47 deletions.
83 changes: 43 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,44 +91,47 @@ coverage report -m
## Test Coverage

```
Name Stmts Miss Cover Missing
---------------------------------------------------------
app.py 18 0 100%
const.py 4 0 100%
db.py 14 0 100%
depends.py 16 0 100%
dto/__init__.py 0 0 100%
dto/cart.py 19 0 100%
dto/like.py 4 0 100%
dto/product.py 18 0 100%
exception.py 14 1 93% 30
orm/__init__.py 5 0 100%
orm/base.py 8 0 100%
orm/cart.py 10 0 100%
orm/like.py 10 0 100%
orm/product.py 12 0 100%
orm/review.py 8 0 100%
orm/user.py 9 0 100%
presentation/__init__.py 0 0 100%
presentation/cart.py 23 0 100%
presentation/like.py 15 0 100%
presentation/ping.py 5 0 100%
presentation/product.py 19 0 100%
repository/base.py 16 0 100%
repository/cart.py 7 0 100%
repository/like.py 8 0 100%
repository/product.py 8 1 88% 16
service/__init__.py 0 0 100%
service/cart.py 27 0 100%
service/like.py 21 0 100%
service/product.py 24 0 100%
settings.py 16 1 94% 19
tests/conftest.py 49 0 100%
tests/e2e/test_cart.py 41 0 100%
tests/e2e/test_like.py 23 0 100%
tests/e2e/test_ping.py 8 0 100%
tests/e2e/test_product.py 36 0 100%
tests/helper.py 12 0 100%
---------------------------------------------------------
TOTAL 527 3 99%
❯ coverage report -m
Name Stmts Miss Cover Missing
------------------------------------------------------------
app.py 18 0 100%
const.py 4 0 100%
db.py 14 0 100%
depends.py 16 0 100%
dto/__init__.py 0 0 100%
dto/cart.py 19 0 100%
dto/like.py 4 0 100%
dto/product.py 18 0 100%
exception.py 14 0 100%
orm/__init__.py 5 0 100%
orm/base.py 8 0 100%
orm/cart.py 10 0 100%
orm/like.py 10 0 100%
orm/product.py 12 0 100%
orm/review.py 8 0 100%
orm/user.py 9 0 100%
presentation/__init__.py 0 0 100%
presentation/cart.py 23 0 100%
presentation/like.py 15 0 100%
presentation/ping.py 5 0 100%
presentation/product.py 19 0 100%
repository/base.py 16 0 100%
repository/cart.py 7 0 100%
repository/like.py 8 0 100%
repository/product.py 6 0 100%
service/__init__.py 0 0 100%
service/cart.py 27 0 100%
service/like.py 21 0 100%
service/product.py 24 0 100%
settings.py 16 0 100%
tests/conftest.py 49 0 100%
tests/e2e/test_cart.py 41 0 100%
tests/e2e/test_like.py 23 0 100%
tests/e2e/test_ping.py 8 0 100%
tests/e2e/test_product.py 36 0 100%
tests/helper.py 12 0 100%
tests/unit/test_exception.py 9 0 100%
tests/unit/test_settings.py 6 0 100%
------------------------------------------------------------
TOTAL 540 0 100%
```
7 changes: 0 additions & 7 deletions repository/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ def get_greater_than_id(self, id: int):
).filter(
self.model.id > id
).first()

def get_in_id(self, ids: list[int]):
return self.session.query(
self.model
).filter(
self.model.id.in_(ids)
).all()
15 changes: 15 additions & 0 deletions tests/unit/test_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import pytest
from fastapi import status

from exception import BadRequestException, handle_exception


def test_exception_handler_returns_valid_response():
response = handle_exception(None, BadRequestException())
assert response.status_code == status.HTTP_400_BAD_REQUEST


def test_exception_handler_not_implemented():
with pytest.raises(NotImplementedError):
handle_exception(None, RuntimeError())
9 changes: 9 additions & 0 deletions tests/unit/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from sqlalchemy import URL

from settings import Settings


def test_settings_get_db_url_returns_success():
settings = Settings()
url = settings.get_db_url()
assert isinstance(url, URL)

0 comments on commit c690c7d

Please sign in to comment.