phresh-tutorial icon indicating copy to clipboard operation
phresh-tutorial copied to clipboard

Incorrect type hint for delete offer route

Open natuspati opened this issue 2 years ago • 0 comments

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?

natuspati avatar Jul 04 '23 10:07 natuspati