示例#1
0
 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)
示例#2
0
 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)
示例#3
0
文件: main.py 项目: pombredanne/waskr
    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 = {}
示例#4
0
 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)
示例#5
0
    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)
示例#6
0
 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) 
示例#7
0
 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) 
示例#8
0
 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)
示例#9
0
    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)
示例#10
0
    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)
示例#11
0
    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)
示例#12
0
 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)
示例#13
0
 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)