-
Notifications
You must be signed in to change notification settings - Fork 51
Make homu testable #143
Comments
I'd like to help with this! |
Fantastic! You can see examples of homu in action as the @bors-servo account in #142. A lot of the work happens in the parse_commands method, and you can see examples of the bot immediately acting through calls like add_comment that directly affect the state. We're interested in transforming this code so that's it's easier to test, so we can simulate these actions without actually interacting with github. Does that make sense? |
Yeah, makes sense! I'll start to work on this ASAP |
Hey @jdm. I've been reading the code and I think that it needs a big refactor to be fully testable, although it will be a big project. This is my idea:
This approach will allow us to merge code into master while we are working on the refactor, so you would be able to work on new features if needed. Let me know what do you think about this, and if you think if it's worth investing in a big refactor. |
My first question is what kind of testing you believe is possible with the current code. That's always been the biggest challenge, which is why there are no tests yet. |
Yeah, that's definitely tricky. I still have to understand the code better to be able to answer that question properly. |
My point of view is that it's possible to do a relatively small amount of refactoring to remove the direct state updates from the current code and turn it into something that we can start writing simple tests for. That's the same goal that you described, so I don't see why we need a separate plan in order to get there :) |
Hey! I'm still working on this. I've extracted some logic from |
That looks like a good start! I didn't realize how mocking could give us more confidence about the current behaviour without requiring a bunch of invasive changes, so thanks for demonstrating that! The only change that I disagree with right now is having a boolean |
Hi!
I agree with that, but reintroducing verification into the methods isn't possible because I can't mock the verification function for the tests. By the way, is there any easy way I can deploy my version somewhere to test it? |
Is the problem with mocking the verification function because of the partial? If so, we should be able to fix that with a simple change: def _call_verify_auth(username, repo_cfg, state, auth, realtime, my_username):
return verify_auth(username, repo_cfg, state, auth, realtime, my_username) Then make the partials use _call_verify_auth instead of verify_auth, and mocking verify_auth will work as expected. As for deploying, I suspect heroku is your best best. |
I'll try that! def verify_auth(username, repo_cfg, state, auth, realtime, my_username): And we are passing all those arguments to |
Refactor parse_commands to add tests. This PR address #143. This is a first step in making Homu testable. A small refactor has been done, extracting the logic in `parse_commands` to its own functions, to be able to mock the state and add tests. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/homu/149) <!-- Reviewable:end -->
Right now homu is built to interact directly with the github API and buildbot. We want to refactor homu so that its hooks produce a list of actions, and those actions can be run separately to actually invoke them. This would be a similar transformation as servo/upstream-wpt-sync-webhook@4b0f370, which is a flask server that interacts with the github API and was redesigned to be more testable.
The text was updated successfully, but these errors were encountered: