Skip to content

Commit

Permalink
Merge pull request #8 from johnchase/testing
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
johnchase authored Jul 15, 2022
2 parents a540fee + bdf851d commit cbe19d6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ build:
alembic upgrade head

test:
nox -r
nox --session test coverage
36 changes: 36 additions & 0 deletions app/crud/crud_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@


class CRUDItem(CRUDBase[Item, ItemCreate, ItemUpdate]):
"""CRUDItem."""

def create_with_owner(self, db: Session, *, obj_in: ItemCreate, owner_id: int) -> Item:
"""create_with_owner.
Parameters
----------
db : Session
db
obj_in : ItemCreate
obj_in
owner_id : int
owner_id
Returns
-------
Item
"""
obj_in_data = jsonable_encoder(obj_in)
db_obj = self.model(**obj_in_data, owner_id=owner_id)
db.add(db_obj)
Expand All @@ -18,6 +36,24 @@ def create_with_owner(self, db: Session, *, obj_in: ItemCreate, owner_id: int) -
return db_obj

def get_multi_by_owner(self, db: Session, *, owner_id: int, skip: int = 0, limit: int = 100) -> List[Item]:
"""get_multi_by_owner.
Parameters
----------
db : Session
db
owner_id : int
owner_id
skip : int
skip
limit : int
limit
Returns
-------
List[Item]
"""
return db.query(self.model).filter(Item.owner_id == owner_id).offset(skip).limit(limit).all()


Expand Down
16 changes: 8 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def coverage(session):
session.run("coverage", "report")


# @nox.session
# def lint(session):
# session.install("poetry")
# session.run("poetry", "lock", "--no-update")
# session.run("poetry", "install")
# session.run("black", "./app")
# session.run("flake8")
# session.run("pytest", "--isort")
@nox.session
def lint(session):
session.install("poetry")
session.run("poetry", "lock", "--no-update")
session.run("poetry", "install")
session.run("black", "./app")
session.run("flake8")
session.run("pytest", "--isort")


# @nox.session
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ black = "^21.5b2"
codespell = "^2.1.0"
isort = "^5.10.1"
pytest = "^6.2.5"
commitizen = "^2.20.4"
pre-commit = "^2.17.0"
flake8-docstrings = "^1.6.0"
pytest-cov = "^3.0.0"
pytest-isort = "^3.0.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit cbe19d6

Please sign in to comment.