ftw.testing is a Python module that provides an advanced MockTestCase which provides bases on the plone.mocktestcase MockTestCase.
The following additional methos are available:
``self.providing_mock(interfaces, *args, **kwargs)``
Creates a mock which provides ``interfaces``.
``self.mock_interface(interface, provides=None, *args, **kwargs)``
Creates a mock object implementing ``interface``. The mock does not
only provide ``interface``, but also use it as specification and
asserts that the mocked methods do exist on the interface.
``self.stub(*args, **kwargs)``
Creates a stub. It acts like a mock but has no assertions.
``self.providing_stub(interfaces, *args, **kwargs)``
Creates a stub which provides ``interfaces``.
``self.stub_interface(interface, provides=None, *args, **kwargs)``
Does the same as ``mock_interface``, but disables counting of expected
method calls and attribute access. See "Mocking vs. stubbing" below.
``self.set_parent(context, parent_context)``
Stubs the ``context`` so that its acquision parent is ``parent_context``.
Expects at least context to be a mock or a stub. Returns the ``context``.
``self.stub_request(interfaces=[], stub_response=True,
content_type='text/html', status=200)``
Returns a request stub which can be used for rendering templates. With the
``stub respones`` option, you can define if the request should stub a
response by him self. The other optional arguments:
``content_type``: Defines the expected output content type of the response.
``status``: Defines the expected status code of the response.
``self.stub_response(request=None, content_type='text/html', status=200))``
Returns a stub response with some headers and options. When a ``request``
is given the response would append also to the giver request.
The other optional arguments:
``content_type``: Defines the expected output content type of the response.
``status``: Defines the expected status code of the response.
``self.assertRaises(*args, **kwargs)``
Uses ``unittest2`` implementation of assertRaises instead of
``unittest`` implementation.
It also fixes a problem in ``mock_tool``, where the ``getToolByName`` mock had assertions which is not very useful in some cases.
Product's homepage
Requirements:
· Python
· Plone CMS
What's New in This Release: [ read full changelog ]
· Drop official Plone 4.0 support. [jone]
· Component registry layer: use isolated ZCML layers. When using the same layer instances it may conflict with integration or functional testing layers. [jone]
· Add splinter integration and Plone page objects. [jone]
· onegov.ch approved: add badge to readme. [jone]
· MockTestCase: Support Products.PloneHotfix20121106 patch when mocking getToolByName. [jone]
· MockTestCase: add checks that setUp is called correctly. [jone]