Use HTTPStatus constants in place of literals in tests#13298
Use HTTPStatus constants in place of literals in tests#13298dklimpel wants to merge 5 commits intomatrix-org:developfrom
HTTPStatus constants in place of literals in tests#13298Conversation
HTTPStatus constants in place of literals in tests.HTTPStatus constants in place of literals in tests
richvdh
left a comment
There was a problem hiding this comment.
I'm not convinced this is an improvement. For tests, I'd rather we were very explicit about the response code.
(Note that HTTPStatus.* are magic objects rather than simple strings or ints, so comparing them with a string is not a completely trivial operation.)
|
That's ok. I don't prefer any particular direction. But at the moment the tests are different. Perhaps there is a lack of clear guidelines or documentation. |
|
@matrix-org/synapse-core: what does everyone else think about this? I'd rather we used explicit values in test code, and considered use of |
This one is my fault. I prefer the enum values because I can never remember what the 3xx or 2xx status codes (other than 200) mean. But I don't have a particularly strong opinion. Edit:
I'm not sure what you mean here; I thought we parse HTTP status codes as decimal integers and expect them to be an integer within Synapse? If so, I don't see what the problem is with comparisons: >>> from http import HTTPStatus
>>> HTTPStatus.OK == 200
True
>>> HTTPStatus.OK == "200"
False
>>> HTTPStatus.OK == b"200"
False |
This is kinda my point. The spec tends to give numerical values rather than
In this case we're in test code rather than "within Synapse" per se, and the thing we're trying to check is the value that was passed to Mostly I mean I'm twice-shy about considering In other words: I want test code to be as explicit as possible. (On closer inspection, |
|
I don't have a particularly strong opinion either way TBH. |
|
Right, given:
... I'm making an executive decision to reject this PR, with our thanks. @dklimpel if you want to make a PR changing things in the other direction, it would be welcome! 😇 |
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.(run the linters)
Signed-off-by: Dirk Klimpel dirk@klimpel.org