Skip to content

Incorrect type hint for delete offer route #11

@natuspati

Description

@natuspati

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions