3 # Copyright (C) 2014 Simo Sorce <simo@redhat.com>
5 # see file 'COPYING' for use and warranty information
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from string import Template
30 parser = argparse.ArgumentParser(description=\
31 'Run a test Ipsilon instance from the checkout directory')
32 parser.add_argument('--workdir', default=os.path.join(os.getcwd(), 'tmp'),
33 help="Directory in which db/session files are stored")
34 return vars(parser.parse_args())
43 base.dir = "${BASEDIR}"
44 admin.config.db = "${ADMINDB}"
45 user.prefs.db = "${USERSDB}"
47 tools.sessions.on = True
48 tools.sessions.storage_type = "file"
49 tools.sessions.storage_path = "${WORKDIR}/sessions"
50 tools.sessions.timeout = 60
54 CREATE TABLE login_config (name TEXT,option TEXT,value TEXT);
55 INSERT INTO login_config VALUES('global', 'order', 'testauth');
59 CREATE TABLE users(name TEXT, option TEXT, value TEXT);
60 INSERT INTO users VALUES('admin', 'is_admin', '1');
63 if __name__ == '__main__':
68 penv.update(os.environ)
69 penv['PYTHONPATH'] = './'
71 if not os.path.exists(args['workdir']):
72 os.makedirs(args['workdir'])
73 os.makedirs(os.path.join(args['workdir'], 'sessions'))
75 admin_db = os.path.join(args['workdir'], 'adminconfig.sqlite')
76 sql = os.path.join(args['workdir'], 'admin.sql')
77 with open(sql, 'w+') as f:
78 f.write(ADMIN_TEMPLATE)
79 subprocess.call(['sqlite3', '-init', sql, admin_db, '.quit'])
81 users_db = os.path.join(args['workdir'], 'users.sqlite')
82 sql = os.path.join(args['workdir'], 'users.sql')
83 with open(sql, 'w+') as f:
84 f.write(USERS_TEMPLATE)
85 subprocess.call(['sqlite3', '-init', sql, users_db, '.quit'])
87 t = Template(CONF_TEMPLATE)
88 text = t.substitute({'BASEDIR': os.getcwd(),
89 'WORKDIR': args['workdir'],
92 conf = os.path.join(args['workdir'], 'ipsilon.conf')
93 with open(conf, 'w+') as f:
97 p = subprocess.Popen(['./ipsilon/ipsilon', conf], env=penv)