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)
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])
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")
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())
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())
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())
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)
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()
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)
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)
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)
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)
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)
def _setupVocabulary(ztc): from zope.schema.vocabulary import setVocabularyRegistry setVocabularyRegistry(Zope2VocabularyRegistry())
def configure_vocabulary_registry(): setVocabularyRegistry(Zope2VocabularyRegistry())
def test_setVocabularyRegistry(self): r = DummyRegistry() vocabulary.setVocabularyRegistry(r) self.assert_(vocabulary.getVocabularyRegistry() is r)
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)
def tearDownFive(self): """Tear down the Five initialization restoring the previous vocabulary registry. """ setVocabularyRegistry(self._oldVocabularyRegistry)
def setupVocabulary(testcase): from zope.schema.vocabulary import setVocabularyRegistry setVocabularyRegistry(Zope2VocabularyRegistry())