Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 64 lines (47 sloc) 1.42 KB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
yayclient - command-line development tool
"""
import unittest
import getopt
import sys
import os
sys.path.append("tests/pytests")
import DbClient
import load_generator
from post_tests import TestPostFunction
from basic_tests import TestBasicFunctions
from ConfigParser import SafeConfigParser
def main():
os.environ['yay_root'] = os.getcwd()
commands = {
'reset' : reset,
'test' : test,
'bootstrap': bootstrap
}
del sys.argv[0]
cmd = sys.argv[0]
del sys.argv[0]
args = sys.argv
if cmd not in commands:
err_message = ("'%s' is not a command; see -h for more help.") % cmd
print err_message
exit
cfg = SafeConfigParser()
cfg.read(['tests/yay.ini'])
args.insert(0, cfg)
commands[cmd](*args)
def reset(cfg):
DbClient.reset_database(cfg.get('db', 'host'), cfg.get('db', 'database'),
cfg.get('db', 'username'), cfg.get('db', 'password'))
def test(cfg):
basic = unittest.TestLoader().loadTestsFromTestCase(TestBasicFunctions)
post = unittest.TestLoader().loadTestsFromTestCase(TestPostFunction)
suite = unittest.TestSuite([basic, post])
unittest.TextTestRunner(verbosity=2).run(suite)
def bootstrap(cfg, users=5, threads=10, replies=100):
reset(cfg)
load_generator.bootstrap(int(users), int(threads), int(replies))
if __name__ == '__main__':
main()