Back to index

plone3  3.1.7
Classes | Functions | Variables
plone.app.layout.globals.tests.test_interface Namespace Reference

Classes

class  IOne
class  ITwo
class  NotAnInterface

Functions

def test_interface_view
def test_suite

Variables

 optionflags = doctest.REPORT_ONLY_FIRST_FAILURE|doctest.ELLIPSIS

Class Documentation

class plone::app::layout::globals::tests::test_interface::NotAnInterface

Definition at line 16 of file test_interface.py.


Function Documentation

Information about the interfaces of an object

>>> from zope.interface import Interface, implements, directlyProvides, classProvides
>>> from zope.component import provideAdapter, getMultiAdapter
>>> from zope.publisher.interfaces.browser import IBrowserRequest
>>> from zope.publisher.browser import TestRequest

>>> from zope.annotation.interfaces import IAttributeAnnotatable
>>> from zope.annotation.attribute import AttributeAnnotations
>>> provideAdapter(AttributeAnnotations)

>>> from plone.app.layout.globals.tests.test_interface import IOne, ITwo

>>> class One(object):
...     implements(IOne)
...     classProvides(ITwo)

>>> from plone.app.layout.globals.interface import InterfaceInformation
>>> provideAdapter(InterfaceInformation, (Interface, IBrowserRequest), Interface, u'plone_interface_info')

>>> obj = One()
>>> request = TestRequest()

>>> directlyProvides(request, IAttributeAnnotatable)
>>> view = getMultiAdapter((obj, request), name=u'plone_interface_info')

>>> view.provides('plone.app.layout.globals.tests.test_interface.IOne')
True
>>> view.provides('plone.app.layout.globals.tests.test_interface.ITwo')
False
>>> view.provides('plone.app.layout.globals.tests.test_interface.NotAnInterface')
Traceback (most recent call last):
...
ValueError: 'plone.app.layout.globals.tests.test_interface.NotAnInterface' is not a valid Interface.

>>> view.class_provides('plone.app.layout.globals.tests.test_interface.IOne')
False
>>> view.class_provides('plone.app.layout.globals.tests.test_interface.ITwo')
True
>>> view.class_provides('plone.app.layout.globals.tests.test_interface.NotAnInterface')
Traceback (most recent call last):
...
ValueError: 'plone.app.layout.globals.tests.test_interface.NotAnInterface' is not a valid Interface.

Definition at line 19 of file test_interface.py.

00019 
00020 def test_interface_view(self):
00021     """Information about the interfaces of an object
00022     
00023     >>> from zope.interface import Interface, implements, directlyProvides, classProvides
00024     >>> from zope.component import provideAdapter, getMultiAdapter
00025     >>> from zope.publisher.interfaces.browser import IBrowserRequest
00026     >>> from zope.publisher.browser import TestRequest
00027     
00028     >>> from zope.annotation.interfaces import IAttributeAnnotatable
00029     >>> from zope.annotation.attribute import AttributeAnnotations
00030     >>> provideAdapter(AttributeAnnotations)
00031     
00032     >>> from plone.app.layout.globals.tests.test_interface import IOne, ITwo
00033     
00034     >>> class One(object):
00035     ...     implements(IOne)
00036     ...     classProvides(ITwo)
00037     
00038     >>> from plone.app.layout.globals.interface import InterfaceInformation
00039     >>> provideAdapter(InterfaceInformation, (Interface, IBrowserRequest), Interface, u'plone_interface_info')
00040     
00041     >>> obj = One()
00042     >>> request = TestRequest()
00043     
00044     >>> directlyProvides(request, IAttributeAnnotatable)
00045     >>> view = getMultiAdapter((obj, request), name=u'plone_interface_info')
00046     
00047     >>> view.provides('plone.app.layout.globals.tests.test_interface.IOne')
00048     True
00049     >>> view.provides('plone.app.layout.globals.tests.test_interface.ITwo')
00050     False
00051     >>> view.provides('plone.app.layout.globals.tests.test_interface.NotAnInterface')
00052     Traceback (most recent call last):
00053     ...
00054     ValueError: 'plone.app.layout.globals.tests.test_interface.NotAnInterface' is not a valid Interface.
00055     
00056     >>> view.class_provides('plone.app.layout.globals.tests.test_interface.IOne')
00057     False
00058     >>> view.class_provides('plone.app.layout.globals.tests.test_interface.ITwo')
00059     True
00060     >>> view.class_provides('plone.app.layout.globals.tests.test_interface.NotAnInterface')
00061     Traceback (most recent call last):
00062     ...
00063     ValueError: 'plone.app.layout.globals.tests.test_interface.NotAnInterface' is not a valid Interface.
00064     """

Definition at line 65 of file test_interface.py.

00065 
00066 def test_suite():
00067     suite = unittest.TestSuite()
00068     suite.addTest(doctest.DocTestSuite(optionflags=optionflags))
    return suite

Variable Documentation

plone.app.layout.globals.tests.test_interface.optionflags = doctest.REPORT_ONLY_FIRST_FAILURE|doctest.ELLIPSIS

Definition at line 4 of file test_interface.py.