Open jerneyio opened 9 years ago
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @test_user_selection_ignore_this (or someone else) soon.
Warning
Thanks for doing this work! I'm not sure precisely when I'll have time to review it, but my intention is to do so this week!
Sounds good to me. I'll give you a shout next week if I haven't heard back from you by then.
Well now I know what the 'Close and comment' button does...
Wow. I just glanced through each of the commits, and this looks like a fairly complicated series of refactorings and test harness changes. Any chance you could summarize the new design so I can orient my feedback appropriately? Additionally, where can I learn more about the mocking and @patch stuff? I have ~0 experience with idiomatic testing in Python.
Not a problem. I'll address Mock and patch first.
You can learn more about Python's mock library here and here. The reason behind using the library is twofold:
random
, for example, so we can fix the output of calls to random.choice
for testing. Here's an overview of the design:
payloadreceiver.py
- receives JSON payloads. Entry point to the application.payloadhandler.py
-
TravisPayloadHandler
- this class handles JSON payloads received from TravisCIGithubPayloadHandler
- this class handles JSON payloads received from Githubgithubapiprovider.py
-
GithubApiProvider
- this class handles requests to the Github API. This is largely unchanged from the existing code except for the addition of methods that get and post review comments.travisciapiprovider.py
-
TravisCiApiProvider
- this class handles requests to the Travis CI API.errorparser.py
-
ServoErrorParser
- this class handles parsing the log file generated by Travis CI's calls to tidy.py, and return the errors in a structured format.test.py
- handles all the testingresources/*
- these files are used for testing. I left the JSON files from the previous tests in there in case we need to do integration testing.If you'd like anymore info, or have any questions, just let me know.
@jdm, if you'd rather chat about the design, tests, etc., on the Servo IRC, just let me know. I'm free most days after 5:00 PM EST
Ok, I finally finished reading the changes; apologies for the long delay! Thank you again for tackling this, and for spending time to improve the architecture of the code! Generally, I think many of the changes are for the better - we've got some decent separation of concerns now, and it looks like it's easier to both read and reason about in many cases. I'm less clear on the benefits of the test changes; I hope the comments I left in test.py are able to explain my concerns effectively. I am particularly interested in restoring the integration tests that previously existed; I believe those tests verify many of the properties of the bot's behaviour that are most important, and they do so without focusing on the actual implementation. Does that make sense?
No worries on the delay, I appreciate you taking the time to look over the code. Thank you for the valuable feedback, as well. Outside of test.py, I believe we're on the same page with the changes that should be made.
As far as test.py is concerned, I'd like to discuss what kind of tests should be run and where. I'm relatively new to testing, and after reviewing your comments I see I may have gone on a unit testing rampage in an effort to get as much code coverage as possible. Before I do any refactoring of test.py, I'd like to make sure we agree on what should be done. Here's what I propose:
NotImpelementedError
is raised should be removed. They don't buy us much.PayloadHandler
classes should be removed in favor of integration tests that cover different use cases. This would include bringing back the previously existing integrations tests for GithubPayloadHandler
and adding integration tests for TravisPayloadHandler
What do you think?
Guh, sorry about the long delay.
I plan to rebase this on top of #33 once those changes merge, for the record!
A lot of refactoring took place, mostly moving code into classes and removing existing tests in favor of using python's unittest module.
I still need to determine a way to test this to make sure the CGI Script reacts properly to the json inputs (possibly just integration tests).
PR for: https://github.com/servo/servo/issues/7480