the time taken to write something that mocks a database is orders of magnitude more than just testing on a separate database instance.
db(db.Budget_BD_Resources.BudgetBD==bd).select(db.Budget_BD_Resources.Amount.sum(),groupby=db.Budget_BD_Resources.BudgetBD)
As for "decoupling", I'm a big believer that webapp tests should need to be executed with behavioural tests, not unit-tests.
Of course business logic core modules (if any) can be tested with unittest, but that's actually "outside" the scope of web2py..... they're just standard python modules if you kept them just "business logic" and they don't interfere with presentation logic.
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.
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)
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)
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.
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
But this has a smell of having your unit-test testing the framework, more than your code, the same problem that exists in django.
Ideally this should be avoided...
And it can - with mock-objects that substute the db object, emulating it's api-calls that your code is using. It's eazier than you might think, using the 'mock' library - check out the link I posted.
It would also be even faster than a memory-database, and much simpler.
The only downside is that anytime your query-code changes, you would have to update your tests...
I'm not sure how you are goint to implement an in-memory relational-database that can be used woth the same db-object-using code - that sounds ineresting...
db = DAL('sqlite:memory') What would happen to the schema-log file?
Wouldn't having the same model-code using 2 different databases, mess up the log and brake automatic-migration capability?
I mean, you could turn migration off for when testing, but wouln't that prevent the model from being able to actually create your tables?
Or does web2py manage different logs for each connection-url?
And then there is the issue of having differences between schema definitions using different databases, for example the way booleans are implemented, or having missing features in the dal, like supporting multy-column unique-constrains... I'm not even sure if sqlight supports that at all... How would this approach handle such issues?
I have some more questions about using an alternative database for testing.What would happen to the schema-log file?
Wouldn't having the same model-code using 2 different databases, mess up the log and brake automatic-migration capability?
I mean, you could turn migration off for when testing, but wouln't that prevent the model from being able to actually create your tables?
Or does web2py manage different logs for each connection-url?
And then there is the issue of having differences between schema definitions using different databases, for example the way booleans are implemented, or having missing features in the dal, like supporting multy-column unique-constrains... I'm not even sure if sqlight supports that at all... How would this approach handle such issues?
Using this, would it mean that no file is generated in the file-system?Does this mean that all that temporary-folder/file jazz would not be required?In that case, you could even not have to clear-out the tables from the previous test-run, as there wouldn't be any, right?But it should still require clearing-out data between-tests, right?And what about the schema-log file? Would that still have to be created? It would seem redundant, as there would not be any use for it - unless consecutive-tests are modifying the schema, and committing.
Now the only question that would remain, is weather this means that test-performance using this, would be fast enough for that to be considered fitting for interactive-TDD...
Otherwise the dal-using-code would still be better-off 'mocked' away...
Arnon, how many use cases does your application have?
Is time to run tests really a bottleneck in your case?
Just as an example to how the absent of communication has led to porrer-and-unnecessary implementation(s):In we2py_utils, I've seen Thadeus used 'sqlight:memory' in the connection-string. This completely circumvent the entire issue that many implementations I had seen have been hammering on - the issue of having to clear-out the fixtures on each test-session-setup, and the issue of having an sqlight-file locked by another process. When you use an in-memory instance of sqlight in your setup-implementation, you are completely avoiding such issues, AND it's faster AND simpler.
The book, in that case, would act as an information-centralization tool. So it's not about the book. Its about information-centralization/consolidation, for the sake of research-efficiency, and prevention of duplication-of-efforts. There may be other tools/platforms that can searve this role.
The book might be a less-efficient way than others, in terms of how frequent it is updated.
I am deliberatelty refraining from specific suggestions, because the actual solution-implementation is less important than understanding the problem. The need is more important than the strategy for meeting it.
Where I think a book is a terrible option, is when concearning exposure of frequently-updating information. Say, announcement of a feature-project that is underway, This should belong to a "news-feed", a newsletter, or both.
The 2 worlds might meet, say, as an announcement for additions to the book, with links to the chapters.
The FAQ is really old and dated, so I think it should be updated as well. And it uses some usefull categories, that should be retargeted to a newsfeed.
--
There doesn't necessarily have to be a formal-road-map "process" in existence, for there to be a "road-map-section" in the web2py website.
For example, I like how Redmine's road-map section is structured:
As for announcement, I disagree - That's another duplication-of-efforts and multiplication that creates confusion
- if there is already an maintained tweeter-feed, that it should be used - embedding a tweeter feed into a website is common and trivial nowadays - people expect it.
Book-updates should be linked-into from that tweeter-feed.
--
Well, the way I understand it, the admin-app is a web2py app, and so is the examples-app - which is the we2py website, so assuming the admin-app uses a component for that tweeter-feed, then including it in the web2py website should be as trivial as adding it to the examples-app. Is this what you mean? If so, why should I bother figuring out how to copy that component so it welds-in well with the examples? Shouldn't the ideal person to do that would be the person who writes/maintains these apps? It would probably take him a fraction of the effort it would take me to do that...
As for coordination, I see what you're getting at with the temper thing, but is it really that much of a stretch to expect an open-source project, even a purely-volunteering-base one, to already have coordination-roles assigned to contributors?
I have zero experience and/or interest in being a coordinator for an open-source project, but I am sure there are many people, even in this community, who would be better suited.
Perhaps, but if they're not interested (or can contribute more value to the framework in some other way), that may just leave you. If you're not interested, why should anyone else be?
For further reading, see http://en.wikipedia.org/wiki/Comparative_advantage.
I think you would need a formal process to determine which items will make it into which releases.
Not sure what you mean about duplication. If you have something to announce, post about it here.
Not sure what you mean about duplication. If you have something to announce, post about it here.That's even worse...Now you are suggesting a 3'rd avenue...What I mean by "duplication", is that you have multiple places that need to get updated every time an announcement is in order.By your suggestion, let's take the recent 2.4.7 release, that Massimo just posted here - He would then have to post it also in the tweeter-feed, as well as update the book.That's a duplication of effort, on his part.
Perhaps, but if they're not interested (or can contribute more value to the framework in some other way), that may just leave you. If you're not interested, why should anyone else be?Because other people are different than me. :)They might like this sort of thing.
For further reading, see http://en.wikipedia.org/wiki/Comparative_advantage.Pffff.... Don't even get me started with Adam-Smith's BS....I liked this quote:"...comparative advantage is a metaphysical assumption, rather than a discovery..."I will only gain better advantage learning thing in order to change them, if the amount of effort I would invest in the practice of learning, would be negated by the value I gain from "consecutive" changes I later make. It "pre-assumes" that there would be such changes...
Long-term investment are only profitable in "iterative" occurrences, in which each consecutive occurrence gains more benefit, reducing the overall impact of the up-front investment. In case of a one-off action one needs to take, the invested-effort becomes unprofitable.
Ok, I get it now. But still, the most efficient way would be that the people with the most experience in a given area, would be the ones to maintain it. You are putting a restriction on scgedule that does not apply here. Within a time-frame that is smaller than what an experienced person has available, than you are right. But as you said, web2py does not have a formal release-cycle, and there is currently no incentive in existence for defining one. So, in other words, your example is correct, only when applied to a scheduled-project, which web2py clearly is not, by your standards. So in that case, experienced person B would be most suited for doing both assignments. The overall community-time invested would be only 4 hours. It may take longer to complete schedule-wise, but that has no relevance to an un-scheduled project. It may take Massimo even a few months to get to that, for all I care, it would still remain more efficient.
I think that 140 charcters is more than sufficient for announcements.
I also think that one may be able to demostrate that the tweeter-community at large would agree with this assertion.
Only for announcements that include links to the real announcement.
2.4.7 is out: http://web2py.com/init/default/changelog
2.4.7 is out:pypy support, thanks Niphlodmore bug fixes
Sounds like that would be a biased sample.
However, it seems that our common interest for a road-map, may not fit the way you operate - as you said, if developers don't need a feature, it will not be written.This nulls the possibility of web2py developers answering the needs of web2py users.
I agree that a road-map should not contain deadlines - that makes sense (I hate deadlines...:) ) - this way more efficient usage of man-power would be possible, as the "eventual existence" of a well-written feature, is in most cases of higher-priority to users than a poorly-written-immediate-availability of that same feature. This way, the person with the most experience/knowledge of a given section of the code, would be the one to develop that feature, however long it may take for him to get to it.That was the point I tried to convey to Anthony - it feels like we see more eye-to-eye on this point.
--
As for users=developers - yes you are right. I may have a different expectation than what in expected/accepted in the web2py community. That would be a flaw of communication on the part of the web2py community/developers/maintainers/managers etc.
Arnon, it is more than a little frustrating having a discussion with you, as it appears you don't really pay much attention to what others are saying. If you go back, you will see I have already addressed your argument. You are correct that we make different assumptions, but the differences are not where you think. My only assumption is that it is better to have a given feature sooner rather than later. On the contrary, you seem to be completely indifferent between having a feature available now and having it available at some indefinite future time. In your world, I suppose it would make sense to find the single most productive programmer on the planet, and let that person write all the software for all of humanity. Unfortunately, I think you're the only guy living in your world. If you can't see why it would be better to have software available sooner rather than later (or at least comprehend why most other people would have that preference), then I'm afraid you are beyond any help we can provide to you here.
As for users=developers - yes you are right. I may have a different expectation than what in expected/accepted in the web2py community. That would be a flaw of communication on the part of the web2py community/developers/maintainers/managers etc.
No, I believe the flaw lies elsewhere in this case. I will leave it as an exercise for you to figure it out. ;-)
--Anthony
---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+un...@googlegroups.com.