Il giorno giovedì 16 maggio 2013 13:03:33 UTC+2, Arnon Marcus ha scritto: > > > On Thursday, May 16, 2013 11:37:59 AM UTC+3, Niphlod wrote: >> >> the time taken to write something that mocks a database is orders of >> magnitude more than just testing on a separate database instance. > > > And the execution-time of tests that use a database is > orders-of-magnitude longer than tests that don't - it's not as > trivial-a-decision as it seems. >
uhm. How many tests do you want to run in a day ? let's say a test run takes 20 minutes. You can spin 72 jobs a day. Need more ? Spin another VM.... days where processing power was limited are gone for good. > But as I said, the suggestion is not to mock-out the entire > persistence-layer, that is actually considered a bad idea, because of the > reasons we both acknowledge. > So the optimal solution should be neither. It should be something 'clever' > in-between these two extremes. > For example, the 'mock' library provides an api-free approach, that > enables you to monkey-patch/override a highly-complex set of > recursive/procedural-calls. > For instance, consider a highly-complex query, such as: > > db(db.Budget_BD_Resources.BudgetBD==bd).select(db.Budget_BD_Resources. > Amount.sum(),groupby=db.Budget_BD_Resources.BudgetBD) > > uhm2. This is just asking for nightmares. If you want speed (don't want to involve a database) you test "transformations", not the fetch-transform couple. > You could theoretically monkey-patch this whole statement in it's entirety > (or any part of it), so it returns whatever you want (say, a pre-made > 'rows' instance with 'row'-instances inside) > The 'mock' library should allow you to do that, wile constraining the > monkey-patch to a temporary execution-context, and tear-it-off > automatically at the end of the test (either with a decorator, or a > context-manager that is provided in the library) > > Good luck :D -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.