Jastor11 / phresh-tutorial

A fully functional FastAPI application that acts as a marketplace for cleaners and potential cleaning jobs.
221 stars 47 forks source link

Incorrect type hint for delete offer route #11

Open natuspati opened 1 year ago

natuspati commented 1 year ago

I'm on part-11-marketplace-functionality-in-fastapi/ branch.

TestRescindOffers.test_user_can_successfully_rescind_pending_offer() fails because of Pydantic model type check:

pydantic.error_wrappers.ValidationError: <exception str() failed>

RESCIND_OFFER_QUERY should return number of the deleted rows (iirc it's the default behavior of relational DBs), so return type of OffersRepository.rescind_offer() should be int (also change type in offers:rescind-offer-from-user route from OfferPublic to int).

However, with pytetst --pdb, the error states that it received None type, so the test fails with int and OfferPublic type hints. It's expected as the original query has no RETURNING statement.

I added RETURNING user_id; to RESCIND_OFFER_QUERY and changed type hints to int. The test passes this way.

What would be the correct solution if we want to return empty body on successful Offer DELETE request?