class AdvTestCase(B3TestCase): """ Ease test cases that need an working B3 console and need to control the ADV plugin config """ def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.adminPluginConf = CfgConfigParser() self.adminPluginConf.load(ADMIN_CONFIG_FILE) self.adminPlugin = AdminPlugin(self.console, self.adminPluginConf) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.startup() self.log.propagate = True global ADV_CONFIG_CONTENT, ADV_CONFIG_FILE, ADMIN_CONFIG_FILE, timer_patcher if os.path.exists(ADV_CONFIG_FILE): with open(ADV_CONFIG_FILE, 'r') as f: ADV_CONFIG_CONTENT = f.read() timer_patcher = patch('threading.Timer') timer_patcher.start() def tearDown(self): B3TestCase.tearDown(self) timer_patcher.stop() unstub() def init_plugin(self, config_content=None): conf = None if config_content: conf = XmlConfigParser() conf.setXml(config_content) elif ADV_CONFIG_CONTENT: conf = XmlConfigParser() conf.setXml(ADV_CONFIG_CONTENT) else: unittest.skip("cannot get default plugin config file at %s" % ADV_CONFIG_FILE) self.p = AdvPlugin(self.console, conf) self.p.save = Mock() self.conf = self.p.config self.log.setLevel(logging.DEBUG) self.log.info( "============================= Adv plugin: loading config ============================" ) self.p.onLoadConfig() self.log.info( "============================= Adv plugin: starting =================================" ) self.p.onStartup()
class AdvTestCase(B3TestCase): """ Ease test cases that need an working B3 console and need to control the ADV plugin config """ def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) global ADV_CONFIG_CONTENT, ADV_CONFIG_FILE, ADMIN_CONFIG_FILE, timer_patcher if os.path.exists(ADV_CONFIG_FILE): with open(ADV_CONFIG_FILE, 'r') as f: ADV_CONFIG_CONTENT = f.read() self.adminPluginConf = CfgConfigParser() self.adminPluginConf.load(ADMIN_CONFIG_FILE) self.adminPlugin = AdminPlugin(self.console, self.adminPluginConf) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.startup() self.log.propagate = True timer_patcher = patch('threading.Timer') timer_patcher.start() def tearDown(self): B3TestCase.tearDown(self) timer_patcher.stop() unstub() def init_plugin(self, config_content=None): conf = None if config_content: conf = XmlConfigParser() conf.setXml(config_content) elif ADV_CONFIG_CONTENT: conf = XmlConfigParser() conf.setXml(ADV_CONFIG_CONTENT) else: unittest.skip("cannot get default plugin config file at %s" % ADV_CONFIG_FILE) self.p = AdvPlugin(self.console, conf) self.p.save = Mock() self.conf = self.p.config self.log.setLevel(logging.DEBUG) self.log.info("============================= Adv plugin: loading config ============================") self.p.onLoadConfig() self.log.info("============================= Adv plugin: starting =================================") self.p.onStartup()
class AdvTestCase(B3TestCase): """ Ease test cases that need an working B3 console and need to control the ADV plugin config """ def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.adminPlugin = AdminPlugin(self.console, ADMIN_CONFIG) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.startup() self.log.propagate = True def tearDown(self): B3TestCase.tearDown(self) unstub() def init_plugin(self, config_content=None): conf = None if config_content: conf = XmlConfigParser() conf.setXml(config_content) elif default_plugin_content: conf = XmlConfigParser() conf.setXml(default_plugin_content) else: unittest.skip("cannot get default plugin config file at %s" % default_plugin_file) self.p = AdvPlugin(self.console, conf) self.p.save = Mock() self.conf = self.p.config self.log.setLevel(logging.DEBUG) self.log.info("============================= Adv plugin: loading config ============================") self.p.onLoadConfig() self.log.info("============================= Adv plugin: starting =================================") self.p.onStartup()
class AdvTestCase(B3TestCase): """ Ease testcases that need an working B3 console and need to control the ADV plugin config """ def setUp(self): self.timer_patcher = patch('threading.Timer') self.timer_patcher.start() self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.startup() self.log.propagate = True def tearDown(self): B3TestCase.tearDown(self) self.timer_patcher.stop() def init_plugin(self, config_content=None): conf = None if config_content: conf = XmlConfigParser() conf.setXml(config_content) elif os.path.exists(default_plugin_file): conf = default_plugin_file else: unittest.skip("cannot get default plugin config file at %s" % default_plugin_file) self.p = AdvPlugin(self.console, conf) self.conf = self.p.config self.log.setLevel(logging.DEBUG) self.log.info("============================= Adv plugin: loading config ============================") self.p.onLoadConfig() self.log.info("============================= Adv plugin: starting =================================") self.p.onStartup()