Exemplo n.º 1
0
def setUp(test=None):
    """Set up for schooltool.relationship doctests.

    Calls Zope's placelessSetUp, sets up annotations and relationships.
    """
    setup.placelessSetUp()
    setup.setUpAnnotations()
    setUpRelationships()
Exemplo n.º 2
0
def setUp(test):
    formSetUp(test)
    component.provideAdapter(TestTemplate, name='layout')
    setup.setUpAnnotations()
    setup.setUpDependable()
    setup.setUpTraversal()
    setup.setUpSiteManagerLookup()
    site = setup.rootFolder()
    setup.createSiteManager(site, setsite=True)
    test.globs['site'] = site
Exemplo n.º 3
0
def setUp(test):
    setup.placelessSetUp()
    from z3c.form import testing
    testing.setupFormDefaults()
    vr = getVocabularyRegistry()
    from schooltool.basicperson.vocabularies import groupVocabularyFactory
    from schooltool.basicperson.vocabularies import advisorVocabularyFactory
    vr.register('schooltool.basicperson.group_vocabulary',
                groupVocabularyFactory())
    vr.register('schooltool.basicperson.advisor_vocabulary',
                advisorVocabularyFactory())
    setUpRelationships()
    setUpAnnotations()
Exemplo n.º 4
0
def catalogSetUp(test):
    """This code is deprecated, to be used only by old evolution tests."""
    setup.placefulSetUp()
    setup.setUpTraversal()
    setUpAnnotations()

    # this is code to set up the catalog for unit testing. it could
    # be extracted and put into general setup functionality

    # Make sure objects can be keyreferenced - necessary for int ids to
    # work:

    from zope.component import provideAdapter
    from persistent.interfaces import IPersistent
    provideAdapter(StupidKeyReference, [IPersistent], IKeyReference)

    # Provide the int id subscribers:

    from zope.component import provideHandler
    from zope.intid import addIntIdSubscriber, removeIntIdSubscriber
    from zope.location.interfaces import ILocation
    from zope.lifecycleevent.interfaces import IObjectAddedEvent
    from zope.lifecycleevent.interfaces import IObjectRemovedEvent
    provideHandler(addIntIdSubscriber,
                   [ILocation, IObjectAddedEvent])
    provideHandler(removeIntIdSubscriber,
                   [ILocation, IObjectRemovedEvent])

    # And the catalog subscribers:

    from zope.catalog import catalog
    from zope.catalog.interfaces import ICatalogIndex
    from zope.intid.interfaces import IIntIdAddedEvent,\
         IIntIdRemovedEvent
    from zope.lifecycleevent.interfaces import IObjectModifiedEvent
    provideHandler(catalog.indexAdded,
                   [ICatalogIndex, IObjectAddedEvent])
    provideHandler(catalog.indexDocSubscriber,
                   [IIntIdAddedEvent])
    provideHandler(catalog.reindexDocSubscriber,
                   [IObjectModifiedEvent])
    provideHandler(catalog.unindexDocSubscriber,
                   [IIntIdRemovedEvent])
Exemplo n.º 5
0
def docSetUp(test=None):
    zope_setup.placefulSetUp()
    zope_setup.setUpAnnotations()
    zope_setup.setUpTraversal()
    test.globs['app'] = setUpSchoolToolSite()
    setUpRelationships()

    provideAdapter(getSchoolYearContainer)
    provideAdapter(getTermContainer, (Interface,))
    provideAdapter(getSchoolYearForTerm)
    provideAdapter(getCourseContainer)
    provideAdapter(getCourseContainerForApp)
    provideAdapter(getSectionContainer)
    provideAdapter(getTermForSection)
    provideAdapter(getTermForSectionContainer)
    provideAdapter(getTimetableContainer)
    provideAdapter(getScheduleContainer)
    setUpIntIds()

    provideAdapter(SectionNameChooser, (ISectionContainer,))

    transaction.begin()
def setUp(test):
    placelesssetup.setUp(test)
    setup.setUpAnnotations()
    setup.setUpDependable()
    setup.setUpTraversal()
Exemplo n.º 7
0
def setUp(test):
    setup.placelessSetUp()
    setup.setUpAnnotations()
    setUpRelationships()
Exemplo n.º 8
0
def setUp(test=None):
    """Set up the test fixture for schooltool.app.browser doctests.

    Performs what is called a "placeless setup" in the Zope 3 world, then sets
    up annotations, relationships, and registers widgets as views for some
    schema fields.

    In effect, duplicates a subset of ZCML configuration -- just enough to
    actually render our page templates in unit tests.
    """
    setup.placefulSetUp()
    setup.setUpAnnotations()
    setup.setUpTraversal()
    # relationships
    setUpRelationships()
    # widgets
    ztapi.browserViewProviding(IPassword, PasswordWidget, IInputWidget)
    ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
    ztapi.browserViewProviding(IText, TextAreaWidget, IInputWidget)
    ztapi.browserViewProviding(IBytes, BytesWidget, IInputWidget)
    ztapi.browserViewProviding(IBool, CheckBoxWidget, IInputWidget)
    ztapi.browserViewProviding(IDate, DateWidget, IInputWidget)
    ztapi.browserViewProviding(IInt, IntWidget, IInputWidget)
    ztapi.browserViewProviding(IChoice, ChoiceInputWidget, IInputWidget)
    ztapi.browserViewProviding(ICollection, CollectionInputWidget, IInputWidget)

    ztapi.provideMultiView((IChoice, IIterableVocabulary), IBrowserRequest,
                           IInputWidget, '', DropdownWidget)

    ztapi.provideMultiView((ISet, IChoice), IBrowserRequest,
                           IInputWidget, '', ChoiceCollectionInputWidget)
    ztapi.provideMultiView((IList, IChoice), IBrowserRequest,
                           IInputWidget, '', ChoiceCollectionInputWidget)
    ztapi.provideMultiView((IList, IVocabularyTokenized), IBrowserRequest,
                           IInputWidget, '', OrderedMultiSelectWidget)
    # XXX MultiSelectWidget doesn't work with sets :/
    #     http://www.zope.org/Collectors/Zope3-dev/360
    ztapi.provideMultiView((ISet, IIterableVocabulary), IBrowserRequest,
                           IInputWidget, '', MultiSelectWidget)

    # errors in forms
    ztapi.browserViewProviding(IWidgetInputError, WidgetInputErrorView,
                               IWidgetInputErrorView)


    # Now, the question is: does the speed of the tests run with the
    # setup below justify this complex setup that duplicates the ZCML?
    # For now, I say yes. -- not mg, perhaps alga or gintas

    # ++view++
    ztapi.provideView(None, None, ITraversable, 'view', view)
    ztapi.provideView(None, None, ITraversable, 'resource', resource)

    # schooltool: namespace in tal
    provideAdapter(SchoolToolAPI, (None,), IPathAdapter, 'schooltool')

    # sortby: namespace in tal
    provideAdapter(SortBy, (None,), IPathAdapter, 'sortby')

    # standard_macros, schooltool_macros and schooltool_navigation
    ztapi.browserView(None, 'standard_macros', StandardMacros)
    ztapi.browserView(None, 'view_macros',
                      SimpleViewClass("../../skin/templates/view_macros.pt"))

    ztapi.browserView(None, 'schooltool_macros', SchoolToolMacros)
    ztapi.browserView(None, 'calendar_macros',
                      SimpleViewClass("./templates/calendar_macros.pt"))
    ztapi.browserView(None, 'generic_macros',
                      SimpleViewClass("../../skin/templates/generic_macros.pt"))

    # form macros
    ztapi.browserView(None, 'form_macros', FormMacros)
    import zope.formlib
    base = zope.formlib.__path__[0]
    ztapi.browserView(None, 'widget_macros',
                      SimpleViewClass(os.path.join(base, 'widget_macros.pt')))

    # resources
    class ResourceStub:
        def __init__(self, request):
            self.request = request
        def __getitem__(self, key):
            return ResourceStub(self.request)
        def __call__(self):
            return "a dummy resource"

    for name in ['layout.css', 'schooltool.css', 'schooltool.js',
                 'next.png', 'prev.png', 'favicon.ico',
                 'print.css', 'jquery.js',
                 'zonki-regular.png']:
        ztapi.browserResource(name, ResourceStub)

    # menus
    ztapi.browserView(None, 'view_get_menu', MenuAccessView)
    provideUtility(BrowserMenuStub('schooltool_actions'), IBrowserMenu,
                   'schooltool_actions')

    # `provider` TALES namespaces
    from zope.browserpage import metaconfigure
    from zope.contentprovider import tales
    metaconfigure.registerType('provider', tales.TALESProviderExpression)

    # viewlet manager registrations
    from zope.viewlet import manager
    from schooltool import skin
    name = 'schooltool.Header'
    provideAdapter(
        manager.ViewletManager(name, skin.IHeaderManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.IHeaderManager,
        name=name)

    name = 'schooltool.JavaScript'
    provideAdapter(
        manager.ViewletManager(name, skin.IJavaScriptManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.IJavaScriptManager,
        name=name)

    name = 'schooltool.CSS'
    provideAdapter(
        manager.ViewletManager(name, skin.ICSSManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.ICSSManager,
        name=name)

    name = 'schooltool.MenuBar'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.IMenuBarMenuManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.IMenuBarMenuManager,
        name=name)

    name = 'schooltool.NavigationMenu'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.INavigationManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.INavigationManager,
        name=name)

    name = 'schooltool.ActionsMenu'
    provideAdapter(
        manager.ViewletManager(name, skin.skin.IActionMenuManager),
        (Interface, IDefaultBrowserLayer, IBrowserView),
        skin.skin.IActionMenuManager,
        name=name)