def test_check_config_indexerror(self): commands = waskr.WaskrCommands(argv=None, test=True, parse=False, db=database.conf_db(db=':memory:')) actual = commands.check_config() self.assertFalse(actual)
def test_clean_plugin_option_double_single(self): commands = waskr.WaskrCommands(argv=None, test=True, parse=False, db=database.conf_db(db=':memory:')) actual = commands.clean_plugin_option("--foo-bar") expected = "foo_bar" self.assertEqual(actual, expected)
def __init__(self, argv=None, test=False, parse=True, db=database.conf_db()): if argv is None: argv = sys.argv self.test = test if parse: self.parseArgs(argv) self.config = {}
def test_check_config(self): sys.stderr = MockSys() sys.stdout = MockSys() commands = waskr.WaskrCommands(argv=None, test=True, parse=False, db=database.conf_db(db=':memory:')) commands.add_config('/tmp/waskr.ini') actual = commands.check_config() self.assertTrue(actual) self.assertEqual(type(actual), dict)
def __init__(self, argv=None, test=False, parse=True, db=database.conf_db()): self.db = db if argv is None: argv = sys.argv self.got_plugins = False self.test = test self.config = {} if parse: self.parseArgs(argv)
def test_config_values(self): sys.stdout = MockSys() commands = waskr.WaskrCommands(argv=None, test=True, parse=False, db=database.conf_db(db=':memory:')) commands.add_config('/tmp/waskr.ini') commands.config_values() actual = sys.stdout.captured() print actual expected = u'Configuration file added: /tmp/waskr.ini\nConfiguration file: /tmp/waskr.ini\n\nweb_password = False\ndb_engine = sqlite\nlog_level = DEBUG\nweb_port = 8080\ncache = 10 \nserver_id = 1 \ndb_port = 27017\napplication = main\ndb_location = /tmp\ndb_host = localhost\nplugins = None\nlog_datefmt = %H:%M:%S\nlog_format = %(asctime)s %(levelname)s %(name)s %(message)s\nplugin_path = False\nweb_host = localhost\n' self.assertEqual(actual, expected)
def test_add_config(self): sys.stderr = MockSys() sys.stdout = MockSys() commands = waskr.WaskrCommands(argv=None, test=True, parse=False, db=database.conf_db(db=':memory:')) commands.add_config('/tmp/waskr.ini') actual = sys.stdout.captured() expected = 'Configuration file added: /tmp/waskr.ini' self.assertEqual(actual, expected)