Martin Aspeli, on 2008-06-29:
> Hi guys,
>
> I just wanted to share with you that I *love* mocker and mock based
> testing. :-)
>
> I blogged about it here:
>
> http://martinaspeli.net/articles/mock-testing-with-mocker-and-plone.mocktestcase
>
> I just released plone.mocktestcase 1.0b1:
>
> http://pypi.python.org/pypi/plone.mocktestcase
>
> I'd like get some input on the above article and opinions from anyone
> who tries this. I'd like to merge the article above into
> plone.org/documentation/tutorial/testing at some point too.
Hi Martin,
I have not tried any code (also not from Dexterity), only read your
article. Some things are not clear to me.
- At the end of the first mock example you say: "We must remember to put
the test case into replay mode, using self.replay()." Why? What does
that do?
- In the third mock example you say that we "set the expectation that
lookup_schema() should be called on it once", stressing the word
'once'. Which part of the test code does that? From the paragraphs
after that I *guess* that whenever the code is this:
self.expect(...).result(...)
it implicitly means this:
self.expect(...).result(...).count(1, 1)
Is that a correct guess? If so, I think you should mention that
explicitly, perhaps already in the first mock example.
BTW, if that is correct then I would find "count(0, None)" a more
logical default, so by default no restriction on the number of times
a mocked method is called.
And a question: is there next to mock_utility also something like
mock_tool, so you could you this to mock for example the
portal_catalog? I guess something along these lines might work:
from whereever import CatalogTool
catalog_mock = self.mocker.proxy(CatalogTool())
context_mock = self.mocker.mock()
self.expect(context_mock.portal_catalog).result(catalog_mock).count(0,None)
--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers