-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Add support for hiding and unhiding multiple fullnames #418
Conversation
/u/thorarakis updated hide/unhide endpoints to accept comma-separated list of fullnames. Add method `hide` and `unhide` to the reddit session under ReportMixin.
@@ -59,6 +59,9 @@ Unreleased | |||
reddit. | |||
* **[REDDIT]** Added ``DeprecationWarning`` to :meth:`login` as reddit will | |||
stop supporting cookie-based authentication on 2015/08/03. | |||
* **[FEATURE]** Added :meth:`hide` and :meth:`unhide`, which accept up to 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the feature to the end of the feature list section. I like to try to keep them grouped by category.
""" | ||
|
||
@decorators.restrict_access(scope='report') | ||
def hide(self, thing_id, unhide=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you prefix unhide
with an underscore as _unhide
to indicate that it should not be used directly in this way? This permits us to remove the parameter in the future should we decide to change the implementation without breaking contractual backwards compatibility.
First, thank you for the addition. My in-line comments were very trivial. Aside from those there are two addtions that will be necessary prior to merging your PR.
Line 75 in 3e9c99a
If you're not sure how to run the tests please ask. My only request in such a situation is to keep some simple notes so we can improve the Thanks again! |
Rename unhide to _unhide Remove unnecessary variable urls, use data directly. Change scope of objects.Hideable.hide to 'report'
Anything else?
I managed to figure out the tests. Here are the steps a layman like myself might take:
Let's see what coveralls thinks.
I had flake8 errors in the Travis build. Sorry about that.
Okay, more Travis errors. That Cassette error is the same one that I thought I had fixed. What does it mean? |
new = list(sub.get_new(limit=5, params={'show': 'all', 'count': 1})) | ||
|
||
# Individuals first... | ||
submission = new[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single item hiding and unhiding will already be tested via the submission_test hide and unhide so it isn't necessary.
Pretty good description of your test approach. This should help you out though. The tests are designed to run via Betamax caches the requests and responses to reddit. All tests that make remote requests should have the betamax decorator. Doing this allows the entire test suite to run in seconds rather than multiple tens of minutes. So the trick is to continuously delete the cassette that is created until (1) the test initially passes, and (2) passes again when you immediately re-run the test. If an unexpected request occurs that's not part of the cassette, then betamax will raise an exception. Repeat until the problem is solved. If you get really stuck feel free to pass it along to me until I can take a look. Also, in order for these saved requests to work, they must reply exactly in each run, which means tests cannot have any randomness in them. At the moment the file uploading tests fail because the underlying requests library introduces randomness. I'm working on a fix to ignore that specific randomness. Great work so far! It's very close to being done. |
Remove unnecessary individuals test from the hidebatch test. Produced a new cassette which should work on Travis.
I don't think If you want me to use something other than get_new, I would probably start with by_id or get_info, rather than using refresh. Then at least it will be a single call. What are your thoughts? This new cassette should work. I hope ✓ |
Looks great thanks!
The only difference would be if someone else adds a submission during the period of time the test is running. For speed reasons, it only matters when the cassette is created, subsequent replays is really fast. That's okay though, I'm okay with it as is. Great job! |
Add support for hiding and unhiding multiple fullnames
/u/thorarakis updated hide/unhide endpoints to accept a comma-separated list of fullnames. Add method
hide
andunhide
to the reddit session under ReportMixin.http://www.reddit.com/r/redditdev/comments/384w9i/hide_and_unhide_endpoints_now_support_comma/
I was hesitant to create the new ReportMixin class, but since all of the other Mixins are scope-based, and hide / unhide are listed under the report scope, I felt it was the right thing to do.
objects.Hideable.hide
now points toreddit_session.hide
, passing its fullname.objects.Hideable.unhide
still point toobjects.Hideable.hide
withunhide=True
.If you try to give more than 50 fullnames, it returns a very generic HTTPError that doesn't explain the problem. Would you like me to do anything about this, or do you think reddit will add an explanation to the error they return?
Please critique!