Nir Soffer has posted comments on this change. Change subject: tests: Add simple mocking library ......................................................................
Patch Set 1: > The tests you linked are a bunch of tests that test nothing. You have a > method that all it does is call lvs with certain parameters in order to > achieve some effect. > You test that you pass said parameters. Which doesn't need testing as we can > clearly see that in the file. It does need testing, the file is a black box for us as you said previously. We can change the implementation, but the call to lvm with those parameters *is* our interface. > And fabricated the response. So the test works. I fabricate multiple calls and responses - a complete flow - you need mocks for this. > Lets just agree to remove the parameter checking as it's completely obsolete > and just say you want to run the function and test it's side effects. doing > xxx = lambda vg: false would have achieved the same results. Lets not agree with that. > Back to my original point. Mocks that do nothing. Mocks that don't hold > state. can just be lambdas and inner functions in python. No need for any > infrastructure. Mock are programmable - the logic of which answer to return is in the test. You don't need to write new class for each test to simulate the specific flow. > Anything more complicated than that. Say a real LVM mock. Would need it's own > class anyway. When you have mocks, you don't need to write stubs like your "real LVM mock". > To reiterate, if tomorrow I change it so that I deactivate the LVs using > sysfs (let's say it is suddenly possible). All of your tests fail. Fix the tests if you broke it. -- To view, visit http://gerrit.ovirt.org/21155 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia5d874f553b6a983652ed745d7d8554716e7a15e Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> Gerrit-Reviewer: Allon Mureinik <[email protected]> Gerrit-Reviewer: Dan Kenigsberg <[email protected]> Gerrit-Reviewer: Douglas Schilling Landgraf <[email protected]> Gerrit-Reviewer: Federico Simoncelli <[email protected]> Gerrit-Reviewer: Nir Soffer <[email protected]> Gerrit-Reviewer: Saggi Mizrahi <[email protected]> Gerrit-Reviewer: Sergey Gotliv <[email protected]> Gerrit-Reviewer: Yaniv Bronhaim <[email protected]> Gerrit-Reviewer: mooli tayer <[email protected]> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: No _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
