Make the rating optional so a seller reply does not leave one - #43
Open
zlexdev wants to merge 1 commit into
Open
Make the rating optional so a seller reply does not leave one#43zlexdev wants to merge 1 commit into
zlexdev wants to merge 1 commit into
Conversation
`orders/review` serves two different acts and the endpoint does not tell them
apart: as the buyer you leave or edit a review with a rating, as the seller you
reply and the site posts `rating=` empty. `Review` modelled only the first —
`rating` was a required `Literal[0, 1, 2, 3, 4, 5]`, and `rating or ''` in
`make_data` made `0` the only way to express "none".
So a seller reply had to be built as `rating=0`. The site accepts it and records
it as the sender's rating on that order. Nothing raises, and it shows up only on
the order page afterwards.
Repro, against the current dev:
await bot.review(order_id="...", text="thanks", rating=0)
posts `rating=` empty — indistinguishable at the call site from meaning to rate.
What changes: `rating` becomes optional and narrows to `1..5`; `reply_review`
states that this is a reply. Omitting the rating without saying so raises
`ReviewRatingRequiredError` at construction, before a request goes out, so the
two acts cannot collapse into one by accident. The reply body is unchanged and
matches a request captured from the site.
`tests/` is new — the Makefile already points `TESTS` at it. Four tests, and the
third fails on the parent commit for the reason above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
orders/reviewserves two different acts and the endpoint does not tell them apart: as the buyer you leave or edit a review with a rating, as the seller you reply and the site postsrating=empty.Reviewmodels only the first.ratingis a requiredLiteral[0, 1, 2, 3, 4, 5], andrating or ''inmake_datamakes0the only way to express "none".So a seller reply has to be built as
rating=0. The site accepts it and records it as the sender's rating on that order. Nothing raises, and it is visible only on the order page afterwards.Repro
On
dev:posts
rating=empty — indistinguishable at the call site from meaning to rate, because0is also the value you would pass if you did.What this changes
ratingbecomes optional and narrows to1..5;reply_review: bool = Falsestates that this is a reply;ReviewRatingRequiredErrorat construction, before a request goes out.The request body is unchanged: a reply still posts
rating=empty, a review still posts its number. Verified field by field against a request captured from the site.tests/is new — theMakefilealready pointsTESTSat it. Four tests;test_omitting_the_rating_without_saying_it_is_a_reply_is_refusedis the one that cannot pass on the parent commit.Named
ReviewRatingRequiredErrorrather thanReviewRatingRequiredto matchRefundError/RaiseOffersErrorand ruff'sN818.Not included
ruff checkreports 13 pre-existing findings elsewhere in the tree. They are left alone so this diff stays about one thing.