-
-
Notifications
You must be signed in to change notification settings - Fork 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
build: add tests #25
build: add tests #25
Conversation
4a7d16f
to
660e2a8
Compare
f60fb77
to
578ba76
Compare
118a132
to
f62ee3e
Compare
06f22eb
to
83e4e63
Compare
83e4e63
to
832a4b9
Compare
832a4b9
to
241551f
Compare
a3227ab
to
d3920b1
Compare
) | ||
TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base.metadata.create_all(bind=engine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to do DB initialization in a global (autouse=True, scope=session) fixture? So that we can take care of removing it after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know, this is more or less a copy-paste of the fastapi tutorials
https://fastapi.tiangolo.com/advanced/testing-database/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge, but these tests will need improvement for sure !
app/api.py
Outdated
@@ -162,7 +161,7 @@ async def create_price( | |||
status_code=status.HTTP_403_FORBIDDEN, | |||
detail="Proof does not belong to current user", | |||
) | |||
db_price = crud.create_price(db, price=price, user=current_user) | |||
db_price = crud.create_price(db, price=price.model_dump(), user=current_user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Price is supposed to be a PriceCreate
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the crud side we have Price(**price, owner=user.user_id)
so I need to check if it works without the model_dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the model_dump
, I get the following error
TypeError: app.models.Price() argument after ** must be a mapping, not PriceCreate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved back the model_dump
inside the crud file 👍
e14db75
to
8e89822
Compare
What
pytest
,pytest-cov
&httpx