예제 #1
0
def setUpRegistration(test):
    setUp(test)

    zope.component.provideAdapter(
        quotationtool.biblatex.bibtex.EntryBibtexRepresentation)

    zope.component.provideAdapter(
        quotationtool.biblatex.bibtex.BibliographyBibtexRepresentation)

    zope.component.provideUtility(
        quotationtool.biblatex.entrytypes.EntryTypesConfiguration(),
        quotationtool.biblatex.interfaces.IEntryTypesConfiguration, 
        '')

    # register vocabularies
    vocabulary.setVocabularyRegistry(vocabulary.VocabularyRegistry())
    vr = vocabulary.getVocabularyRegistry()
    from quotationtool.biblatex.entrytypes import EntryTypeVocabulary
    vr.register('quotationtool.biblatex.EntryTypes', EntryTypeVocabulary)
    from quotationtool.biblatex import vocabulary as vocabularies
    vr.register('quotationtool.biblatex.Pagination', vocabularies.PaginationVocabulary)
    vr.register('quotationtool.biblatex.EditorRoles', vocabularies.EditorRoleVocabulary)
    vr.register('quotationtool.biblatex.Pubstate', vocabularies.PubstateVocabulary)
    vr.register('quotationtool.biblatex.Type', vocabularies.TypeVocabulary)
    vr.register('quotationtool.biblatex.Gender', vocabularies.GenderVocabulary)
    vr.register('quotationtool.biblatex.AuthorTypes', vocabularies.AuthorTypeVocabulary)
    vr.register('quotationtool.biblatex.Language', vocabularies.LanguageVocabulary)
    vr.register('quotationtool.biblatex.Hyphenation', vocabularies.HyphenationVocabulary)
예제 #2
0
 def test_create_vocabulary(self):
     vocabulary.setVocabularyRegistry(DummyRegistry())
     field = Choice(vocabulary="vocab")
     o = object()
     bound = field.bind(o)
     self.assertEqual([term.value for term in bound.vocabulary],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
예제 #3
0
 def setUp(self):
     self.root = setup.placefulSetUp(site=True)
     conn_stub = ConnectionStub()
     def register(arg):
         """i just do not know what is this method doing :("""
     conn_stub.register = register
     self.root._p_jar = conn_stub
     provideAdapter(connectionOfPersistent, adapts=[IPersistent], provides=IConnection, )
     provideAdapter(KeyReferenceToPersistent, adapts=[IPersistent], provides=IKeyReference) 
     provideHandler(setQreatureSiteManager)
     provideHandler(setQuizUtilities)
     provideHandler(addQreatureIntIdSubscriber)
     provideAdapter(SiteManagerAdapter)
     provideAdapter(ResultInterval)
     quiz = Quiz(u'init title',u'init body')
     self.root.__setitem__('quiz', quiz)
     #the site is quiz! not the root
     hooks.siteinfo.site = quiz
     provideAdapter(ResultInterval,adapts=[interfaces.IQuizResult], provides=IResultInterval)
     provideAdapter(QuizAsXML,adapts=[interfaces.IQuiz], provides=interfaces.IQuizAsXML)
     provideAdapter(AttributeAnnotations, adapts=[interfaces.IQuizContainer], provides=IAnnotations)
     provideAdapter(QuizContainerNameChooser, adapts=[interfaces.IQuizContainer], provides=INameChooser)
     vocabulary.setVocabularyRegistry(vocabulary.VocabularyRegistry())
     vr = vocabulary.getVocabularyRegistry()
     vr.register('Quiz Results',depends_voc)
     vr.register('Percentage', percentage)
     vr.register('Quiz Leads', leads_voc)
     provideUtility(flatten, interfaces.IQreatureUtility, "Flatten")
예제 #4
0
 def test_create_vocabulary(self):
     vocabulary.setVocabularyRegistry(DummyRegistry())
     field = Choice(vocabulary="vocab")
     o = object()
     bound = field.bind(o)
     self.assertEqual([term.value for term in bound.vocabulary],
                      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
예제 #5
0
def _clear():
    """Re-initialize the vocabulary registry."""
    # This should normally only be needed by the testing framework,
    # but is also used for module initialization.
    global vocabularyRegistry
    vocabulary._clear()
    vocabularyRegistry = vocabulary.getVocabularyRegistry()
    vocabulary._clear()
    vocabulary.setVocabularyRegistry(ZopeVocabularyRegistry())
예제 #6
0
    def setUpFive(self):
        """Initialize Five without loading the site.zcml file to avoid
        loading all Products.* .

        This basically pushes a special vocabulary registry that
        supports global and local utilities.
        """

        self._oldVocabularyRegistry = getVocabularyRegistry()
        setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #7
0
    def setUpFive(self):
        """Initialize Five without loading the site.zcml file to avoid
        loading all Products.* .

        This basically pushes a special vocabulary registry that
        supports global and local utilities.
        """

        self._oldVocabularyRegistry = getVocabularyRegistry()
        setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #8
0
 def check_constructed(self, cls, okval, badval):
     vocabulary.setVocabularyRegistry(DummyRegistry())
     field = cls(vocabulary="vocab")
     self.assert_(field.vocabulary is None)
     self.assertEqual(field.vocabularyName, "vocab")
     o = object()
     bound = field.bind(o)
     self.assert_(isinstance(bound.vocabulary, SampleVocabulary))
     bound.default = okval
     self.assertEqual(bound.default, okval)
     self.assertRaises(ValidationError, setattr, bound, "default", badval)
예제 #9
0
 def check_constructed(self, cls, okval, badval):
     vocabulary.setVocabularyRegistry(DummyRegistry())
     field = cls(vocabulary="vocab")
     self.assert_(field.vocabulary is None)
     self.assertEqual(field.vocabularyName, "vocab")
     o = object()
     bound = field.bind(o)
     self.assert_(isinstance(bound.vocabulary, SampleVocabulary))
     bound.default = okval
     self.assertEqual(bound.default, okval)
     self.assertRaises(ValidationError, setattr, bound, "default", badval)
def _clear():
    """Re-initialize the vocabulary registry."""
    # This should normally only be needed by the testing framework,
    # but is also used for module initialization.
    global vocabularyRegistry
    # The net effect of these two lines is to have this modules
    # vocabularyRegistry set to zope.schema.vocabulary.VocabularyRegistry()
    vocabulary._clear()
    vocabularyRegistry = vocabulary.getVocabularyRegistry()
    vocabulary._clear()
    # Which we immediately replace
    vocabulary.setVocabularyRegistry(ZopeVocabularyRegistry())
예제 #11
0
def setUpOnlySome(test):
    # we need a vocabulary of languages
    from quotationtool.commentary.source import plainTextCommentFactory, CommentSourceTypeVocabulary
    from quotationtool.commentary.interfaces import ICommentSourceFactory
    zope.component.provideUtility(plainTextCommentFactory,
                                  ICommentSourceFactory,
                                  name='plaintext')
    from zope.schema import vocabulary
    from zope.schema.interfaces import IVocabularyFactory, IVocabulary
    vocabulary.setVocabularyRegistry(vocabulary.VocabularyRegistry())
    vr = vocabulary.getVocabularyRegistry()
    vr.register('quotationtool.commentary.CommentSourceTypes',
                CommentSourceTypeVocabulary)
예제 #12
0
def setUp(suite):  # pragma: no cover
    zope.component.testing.setUp(suite)

    try:
        from Zope2.App.schema import configure_vocabulary_registry
    except ImportError:
        try:
            from zope.schema.vocabulary import setVocabularyRegistry
            from Products.Five.schema import Zope2VocabularyRegistry
        except ImportError:
            pass
        else:
            setVocabularyRegistry(Zope2VocabularyRegistry())
    else:
        configure_vocabulary_registry()
예제 #13
0
    def setUp(self, doctesttest=None):
        CAPlacelessSetup.setUp(self)
        EventPlacelessSetup.setUp(self)
        ContainerPlacelessSetup.setUp(self)
        I18nPlacelessSetup.setUp(self)

        setUpPasswordManagers()
        ztapi.browserView(None, 'absolute_url', AbsoluteURL)
        ztapi.browserViewProviding(None, AbsoluteURL, IAbsoluteURL)

        from zope.security.testing import addCheckerPublic
        addCheckerPublic()

        from zope.security.management import newInteraction
        newInteraction()

        setVocabularyRegistry(None)
예제 #14
0
def doctestSetUp(test):
    site = setup.placefulSetUp(site=True)
    test.globs['rootFolder'] = site

    # session setup
    zope.component.provideAdapter(TestClientId, (IRequest,), IClientId)
    zope.component.provideAdapter(LanguageSession, (IRequest,), 
        ILanguageSession)
    zope.component.provideUtility(CookieClientIdManager(), IClientIdManager)
    rsdc = session.RAMSessionDataContainer()
    zope.component.provideUtility(rsdc, ISessionDataContainer, '')

    # register vocabularies
    vocabulary.setVocabularyRegistry(None)
    vocabulary._clear()
    vr = vocabulary.getVocabularyRegistry()
    
    vr.register('Offered Languages', OfferedLanguagesVocabulary)
예제 #15
0
def setUp(self):
    try:
        from Zope2.App.schema import configure_vocabulary_registry
    except ImportError:
        try:
            from zope.schema.vocabulary import setVocabularyRegistry
            from Products.Five.schema import Zope2VocabularyRegistry
        except ImportError:
            pass
        else:
            setVocabularyRegistry(Zope2VocabularyRegistry())
    else:
        configure_vocabulary_registry()

    zcml.load_config('browser_testing.zcml', plone.schemaeditor.tests)

    # add a test layer to the request so we can use special form templates that don't
    # pull in main_template
    classImplements(BaseRequest, ITestLayer)
예제 #16
0
def setUp(self):
    try:
        from Zope2.App.schema import configure_vocabulary_registry
    except ImportError:
        try:
            from zope.schema.vocabulary import setVocabularyRegistry
            from Products.Five.schema import Zope2VocabularyRegistry
        except ImportError:
            pass
        else:
            setVocabularyRegistry(Zope2VocabularyRegistry())
    else:
        configure_vocabulary_registry()

    zcml.load_config('browser_testing.zcml', plone.schemaeditor.tests)

    # add a test layer to the request so we can use special form templates that don't
    # pull in main_template
    classImplements(BaseRequest, ITestLayer)
예제 #17
0
    def setUp(self, doctesttest=None):
        CAPlacelessSetup.setUp(self)
        ContainerPlacelessSetup.setUp(self)
        EventPlacelessSetup.setUp(self)
        I18nPlacelessSetup.setUp(self)
        AuthenticationPlacelessSetup.setUp(self)
        # Register app-specific security declarations
        protect()

        ztapi.browserView(None, 'absolute_url', AbsoluteURL)
        ztapi.browserViewProviding(None, AbsoluteURL, IAbsoluteURL)

        from zope.app.security.tests import addCheckerPublic
        addCheckerPublic()

        from zope.security.management import newInteraction
        newInteraction()

        setVocabularyRegistry(None)
예제 #18
0
def safe_load_site():
    '''Loads entire component architecture (w/ debug mode on).'''
    cleanUp()
    setDebugMode(1)
    try:
        from Zope2.App import zcml
    except ImportError:
        from Products.Five import zcml
    zcml.load_site()
    try:
        from Zope2.App.schema import configure_vocabulary_registry
    except ImportError:
        try:
            from zope.schema.vocabulary import setVocabularyRegistry
            from Products.Five.schema import Zope2VocabularyRegistry
        except ImportError:
            pass
        else:
            setVocabularyRegistry(Zope2VocabularyRegistry())
    else:
        configure_vocabulary_registry()
    setDebugMode(0)
예제 #19
0
파일: tests.py 프로젝트: goschtl/zope
def _setupVocabulary(ztc):
    from zope.schema.vocabulary import setVocabularyRegistry
    setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #20
0
def configure_vocabulary_registry():
    setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #21
0
def _setupVocabulary(ztc):
    from zope.schema.vocabulary import setVocabularyRegistry
    setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #22
0
 def test_setVocabularyRegistry(self):
     r = DummyRegistry()
     vocabulary.setVocabularyRegistry(r)
     self.assert_(vocabulary.getVocabularyRegistry() is r)
예제 #23
0
 def test_setVocabularyRegistry(self):
     from zope.schema.vocabulary import setVocabularyRegistry
     from zope.schema.vocabulary import getVocabularyRegistry
     r = _makeDummyRegistry()
     setVocabularyRegistry(r)
     self.assertTrue(getVocabularyRegistry() is r)
예제 #24
0
    def tearDownFive(self):
        """Tear down the Five initialization restoring the previous
        vocabulary registry.
        """

        setVocabularyRegistry(self._oldVocabularyRegistry)
예제 #25
0
 def test_setVocabularyRegistry(self):
     r = DummyRegistry()
     vocabulary.setVocabularyRegistry(r)
     self.assert_(vocabulary.getVocabularyRegistry() is r)
예제 #26
0
def configure_vocabulary_registry():
    setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #27
0
    def tearDownFive(self):
        """Tear down the Five initialization restoring the previous
        vocabulary registry.
        """

        setVocabularyRegistry(self._oldVocabularyRegistry)
예제 #28
0
def setupVocabulary(testcase):
    from zope.schema.vocabulary import setVocabularyRegistry
    setVocabularyRegistry(Zope2VocabularyRegistry())
예제 #29
0
 def test_setVocabularyRegistry(self):
     from zope.schema.vocabulary import setVocabularyRegistry
     from zope.schema.vocabulary import getVocabularyRegistry
     r = _makeDummyRegistry()
     setVocabularyRegistry(r)
     self.assertTrue(getVocabularyRegistry() is r)