Merge lp:~michael.nelson/click-reviewers-tools/add-test-without-mocks into lp:click-reviewers-tools
| Status: | Merged |
|---|---|
| Merged at revision: | 534 |
| Proposed branch: | lp:~michael.nelson/click-reviewers-tools/add-test-without-mocks |
| Merge into: | lp:click-reviewers-tools |
| Diff against target: |
776 lines (+356/-212) 17 files modified
clickreviews/cr_common.py (+2/-0) clickreviews/cr_tests.py (+128/-147) clickreviews/tests/test_aaa_example_cr_skeleton.py (+0/-5) clickreviews/tests/test_cr_bin_path.py (+0/-5) clickreviews/tests/test_cr_common.py (+1/-4) clickreviews/tests/test_cr_content_hub.py (+0/-5) clickreviews/tests/test_cr_desktop.py (+0/-5) clickreviews/tests/test_cr_framework.py (+0/-5) clickreviews/tests/test_cr_lint.py (+34/-5) clickreviews/tests/test_cr_online_accounts.py (+0/-5) clickreviews/tests/test_cr_push_helper.py (+0/-5) clickreviews/tests/test_cr_scope.py (+0/-5) clickreviews/tests/test_cr_security.py (+1/-4) clickreviews/tests/test_cr_systemd.py (+0/-5) clickreviews/tests/test_cr_url_dispatcher.py (+0/-5) clickreviews/tests/test_modules.py (+1/-2) clickreviews/tests/utils.py (+189/-0) |
| To merge this branch: | bzr merge lp:~michael.nelson/click-reviewers-tools/add-test-without-mocks |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jamie Strandboge | 2015-10-15 | Approve on 2015-10-21 | |
| Michael Vogt (community) | Approve on 2015-10-20 | ||
|
Review via email:
|
|||
Commit Message
Add non-mocked test example.
Description of the Change
The purpose of this branch is to provide an example test for a click check which doesn't rely on any mocks. As someone unfamiliar with the code, it's quite difficult to follow everything that is currently mocked for each test, and I think it's much clearer and safer to test without mocks wherever possible.
After adding the initial test, I found it passed when run on it's own, but that there were test isolation issues causing failures when running all tests, related to the (currently) global vars UNPACK_DIR and RAW_UNPACK_DIR.
Note: I'm not using 'click build' to build the package because it will in fact fix issues that we're setting up for tests. Here's an example of the new test *failing* when 'click build' is used, because click build fixes the malicious setup, filtering out the .click directory:
http://
Perhaps there's a way to get click build to not run any checks? Not sure.
Details of changes (in order of diff):
1) Ensure UNPACK_DIR and RAW_UNPACK_DIR are reset to None when cleanup_unpack() is called (related to test-isolation, see comments)
2) Moved the creation of all current mock patches from the module level to a function, create_patches, which can be called during setUp (avoids the cyclic import issue mentioned in the deleted comments)
3) Refactored so that the code for starting and stopping the patches is in the one place - the setUp of the base test case.
4) Added a new test case without any mocks with a single test.
5) Added a tests/utils.py with a make_package function for creating potentially invalid packages. The make_package utility is taken from a script we use in myapps. It will need more work.
| Colin Watson (cjwatson) wrote : | # |
| Jamie Strandboge (jdstrand) wrote : | # |
Thank you for this MP. I never really liked how the mocking got so complicated and this should provide a way to move away from that as we move forward. Code looks good. Thanks!

"click build" should not gain options to remove this filtering, no; they have no legitimate use outside of exercising pathological cases. This is a case where it's perfectly reasonable to use dpkg-deb in your test data construction.