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
Moderation streams #1051
Moderation streams #1051
Conversation
Sorry for the commits from my previous pr, I wasn't able to figure out how to not have them attached to this pr. |
I also want to note that the |
@LilSpazJoekp I'll try to get this cleaned up for you. |
Okay, I cleaned up your branch. Please make sure you pull it down before making any changes. Please add a changelog entry for each added item, and we're going to need some tests for each as well. Thanks for the efforts! |
I'll need some help writing the tests, I haven't written unit tests before. |
Is there something specific you'd like? Or more just general guidance? |
I haven’t used Betamax before and not sure how to write the code to generate the cassettes. |
Take a look at the tests for praw/tests/integration/models/reddit/test_subreddit.py Lines 1363 to 1439 in 82d98c5
Your tests will probably look something like this (you could even copy, paste, and modify). The most important parts are the lines like:
This specifies which Betamax cassette to use so that the network interaction can be replayed consistently. This docs page has information about recording new Betamax cassettes, which you will have to do when writing new integration tests. |
@LilSpazJoekp do you still have interest in getting this in? |
@bboe I do. My apologies, I've been busy with reddit and life stuff and haven't had the chance to get this done. |
@bboe This pr is ready. |
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.
Overall solid changes. However, in order to address the decrease in coverage, I think you can implement this piece of code in the subreddit test files:
def test_random(self):
sub = Subreddit(self.reddit, "mod")
submodstream = SubreddditModerationStream(self.reddit, sub)
submodstream.modmail_conversations() # just to cause the untested line to run
assert submodstream.subreddit = Subreddit(self.reddit, "all")
@PokestarFan shouldn’t https://github.com/LilSpazJoekp/praw/blob/45d2793d52d77647b2aa2cdfa7b68fcf5a550cd8/tests/integration/models/reddit/test_subreddit.py#L1506 do the same thing? |
@PokestarFan Never mind I see why. I’ll get that added. |
@LilSpazJoekp my test is a unit test not an integration test so I think it can be seperated. |
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.
Good changes, this should increase coverage back to optimal levels.
@LilSpazJoekp merge with upstream to deal with the conflict or else it won’t resolve and we can’t merge. git remote add upstream <praw-dev-git-url>
git pull --all
git merge upstream/master
# copy-paste lines
... |
@LilSpazJoekp why was this closed? |
Did not mean to close it. |
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.
Looking good, but those tests may need to be ran with a username/password combo.
They all pass with no environment variables set. |
But what if we build new tests? |
See this change here |
So what if we provide all 3 will that break the script? |
Either provide the
Nothing will happen because the |
This will also resolve #1224 because |
Now that tests are passing I'll take a look soon (in the next day or so) to look over the changes. Thanks! |
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.
Thanks for your persistence! This PR is looking nearly complete now that tests have been written and cassettes have been recorded. I've read through the changes and requested some changes. Please let me know if you have questions, need clarification, or if I made any mistake. Looking forward to merging this feature!
@jarhill0 those corrections have been made and committed. |
Thanks for the changes. Things are looking good! I'm not comfortable merging in a change to the way we authenticate test cassettes alongside with a standard new feature, though I am certainly in favor of adding this change as its own PR in a way that is compatible with existing tests. So, at this point I would like to request that the change in
If it's more trouble than it's worth for you to fiddle around with any of options 2–4, I am more than happy to record the cassettes for you. And as I said, I am interested in getting support for testing even with 2FA and refresh tokens and I'd love to see that as a next PR from you. Thanks! |
All it does is just adds a new placeholder; it doesn’t change the auth process for any of the other tests. The placeholder is benign to the other tests because the default reddit instance doesn’t use it and is only used when an overriding reddit instance is used. If you’re still not comfortable with that, would it be possible to merge a pr for adding the refresh token before this one? Reason being is the cassettes are much smaller when large subs are used (due to higher activity). |
My concern is that it should be possible for any PRAW contributor to re-record any cassette if needed, and using different auth schemes for different cassettes disrupts that. That's why I want to hold off on introducing refresh token-based authentication in this particular PR.
Yes, I would be happy to do that! |
I will get that pr started then! |
Are you talking about renaming the non-stream methods? If so, yeah I would agree that they could be named differently, but that would be a breaking change for many bots. If not, I feel it would be best to keep the name of the non-stream method to imply what they will be streaming. Just like the streams for comments and submissions are named after their non-streaming counterpart. |
No, just the streaming methods.
This is a good point, which is why I'm hesitant to say that a rename is required. That said, I worry especially about the generality of the name I'm not really happy with renaming the stream methods because it breaks continuity with their non-streaming counterparts. But neither am I happy with using these names as they feel confusing and non-descriptive. |
Hm, yeah I'm split to. I'm kinda leaning towards keeping the name of the non-streaming counter part to stay consistent with the other stream methods. |
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.
Two minor things. Since you're happy with the streaming method names (which we discussed a few days ago), I'm happy with them too.
And, lastly, if you could squash these commits and then rebase them on top of master, that would be terrific. |
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.
Things look good!
This was a good journey, and it motivated #1233, which is a very useful feature. Thanks for working so hard on this, and I'd love to see more contributions from you in the future! 🎉 |
Feature Summary and Justification
This feature provides the ablilty to stream from subreddit.mod methods.
Added Moderator stream for the following: