def setUp(cls): from OFS.Application import import_products from zope.configuration import xmlconfig import Globals # noqa: F401 import Products.Jobber import_products() cls._ctx = xmlconfig.string(cls.includes) cls._ctx = xmlconfig.file( "/opt/zenoss/Products/Jobber/configure.zcml", Products.Jobber, cls._ctx, )
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 __init__(self, noopts=0, args=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 self.doesLogging: self.setupLogging()
def test_import_products(self): self.makeFakeProducts() self.configure(cfg) from OFS.Application import import_products names = import_products() for name in FAKEPRODUCTS: assert name in names