def setUp(cls): import Products zcml.load_site(force=True) setHooks() # Register Model Catalog related stuff init_model_catalog_for_tests() component.provideHandler(eventlog.trace, (ITestItem, IObjectEvent)) component.provideHandler(eventlog.trace, (IRelationship, IObjectEvent))
def __init__(self, noopts=0, args=None, should_log=None): zope.component.provideAdapter(DefaultTraversable, (None, )) # This explicitly loads all of the products - must happen first! from OFS.Application import import_products import_products() #make sure we aren't in debug mode import Globals Globals.DevelopmentMode = False # We must import ZenossStartup at this point so that all Zenoss daemons # and tools will have any ZenPack monkey-patched methods available. import Products.ZenossStartup unused(Products.ZenossStartup) zcml.load_site() import Products.ZenWidgets load_config_override('scriptmessaging.zcml', Products.ZenWidgets) self.usage = "%prog [options]" self.noopts = noopts self.inputArgs = args # inputArgs was created to allow unit tests to pass in command line # arguments and get around whatever Zope was doing to sys.argv. if self.inputArgs is None: self.inputArgs = sys.argv[1:] self.parser = None self.args = [] self.buildParser() self.buildOptions() # Get defaults from global.conf. They will be overridden by # daemon-specific config file or command line arguments. applyGlobalConfToParser(self.parser) self.parseOptions() if self.options.configfile: self.parser.defaults = self.getConfigFileDefaults( self.options.configfile) # We've updated the parser with defaults from configs, now we need # to reparse our command-line to get the correct overrides from # the command-line self.parseOptions() if should_log is not None: self.doesLogging = should_log if self.doesLogging: self.setupLogging()
def reload_zcml(): gsm = getGlobalSiteManager() old_gsm_dict = gsm.__dict__.copy() try: setSite(None) gsm.__init__(gsm.__name__) # Clean up for clean in cleanups(): clean() # Reload all ZCML zcml._initialized = False zcml._context._seen_files.clear() zcml.load_site() except Exception as e: gsm.__init__(gsm.__name__) gsm.__dict__.clear() gsm.__dict__.update(old_gsm_dict) raise e
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 setUp(cls): cleanup.cleanUp() zcml.load_site(force=True) setDeprecatedManageAddDelete(TestItem) setDeprecatedManageAddDelete(TestFolder)
def setUp(cls): cleanup.cleanUp() zcml.load_site(force=True) component.provideHandler(eventlog.trace, (ITestItem, IObjectEvent)) component.provideHandler(eventlog.trace, (ITestFolder, IObjectEvent))
def afterSetUp(self): cleanup.cleanUp() zcml.load_site(force=True) self.saved = sys.path[:] sys.path.append(ZopeTestCase.__path__[0])
from Products.ZenMessaging.queuemessaging.interfaces import IQueuePublisher from Products.ZenEvents.zeneventmigrate import ZenEventMigrate from Products.ZenUtils.guid.interfaces import IGlobalIdentifier from ConfigParser import ConfigParser from datetime import datetime from itertools import repeat import re import logging log = logging.getLogger('zen.testEventMigrate') #lookup import Globals from Zope2.App import zcml import Products.ZenossStartup zcml.load_site() class MockChannel(object): """ Mocks out an AMQP channel. """ def tx_select(self): pass def tx_commit(self): pass class MockPublisher(object): """