-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
comment moderation fix item value check #799
comment moderation fix item value check #799
Conversation
Nice find! And already well documented, good job. Would you mind changing the commit message title to make it more clear which parts are affected and how? Something like:
|
The item check should happen before we try to access the value not after otherwise it results in a backtracke like this: gunicorn[441]: 2022-02-17 20:46:52,526 ERROR: GET /id/2038/delete/XXXXXXXXXXXX gunicorn[441]: Traceback (most recent call last): gunicorn[441]: File "/opt/isso/lib/python3.6/site-packages/isso/__init__.py", line 150, in dispatch gunicorn[441]: response = handler(request.environ, request, **values) gunicorn[441]: File "/opt/isso/lib/python3.6/site-packages/isso/views/comments.py", line 635, in moderate gunicorn[441]: thread = self.threads.get(item['tid']) gunicorn[441]: TypeError: 'NoneType' object is not subscriptable Now we return a item NotFound instead. Signed-off-by: fliiiix <hi@l33t.name>
5e05127
to
ec0cd4b
Compare
sure how about this? |
Thanks for your contribution! I added some tests for the moderation feature in https://github.com/ix5/isso/tree/moderating-add-testing, would you mind expanding them a bit? Also, the correct response to the |
sure i hope i find some time to think about some more cases and will create a MR when ready https://github.com/fliiiix/isso/tree/moderating-add-testing |
One question i had while working on the tests is would you be open to a refactoring the tests into smaller tests so instead of having |
Thank you for tackling the test deficiencies! I already like what you're doing on your branch a lot.
Hmm, I myself am not too involved in testing conventions, but there's two issues I can think of. So a refactor ideally should include all tests and also make it clear in the docs what testing structure this project expects. For now, I think refactoring only |
Ok i have a look what i can do. From my quick assessment i didn't see something which would take very long to construct for the tests. So while they will run a bit slower overall they should be more clear to read and understand and we reduce the side-efects we have from the things that run before and will influence our test. But I guess i will create then an extra PR where i change that in |
(For anyone coming across this in the future, the testing discussed here was PR'd in #805) |
The item check should happen before we try to access
the value not after otherwise it results in a backtracke like this:
gunicorn[441]: 2022-02-17 20:46:52,526 ERROR: GET /id/2038/delete/XXXXXXXXXXXX
gunicorn[441]: Traceback (most recent call last):
gunicorn[441]: File "/opt/isso/lib/python3.6/site-packages/isso/init.py", line 150, in dispatch
gunicorn[441]: response = handler(request.environ, request, **values)
gunicorn[441]: File "/opt/isso/lib/python3.6/site-packages/isso/views/comments.py", line 635, in moderate
gunicorn[441]: thread = self.threads.get(item['tid'])
gunicorn[441]: TypeError: 'NoneType' object is not subscriptable
Now we return a item NotFound instead.
Signed-off-by: fliiiix hi@l33t.name