forked from internetarchive/infogami
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test
executable file
·64 lines (51 loc) · 1.74 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/env python
import sys
import os, os.path
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import subcommand
import web.test
@subcommand.subcommand()
def doctests(options=None):
"""Run all doctests."""
print >> sys.stderr, "\nRunning doctests\n"
modules = [
"infogami.infobase.common",
"infogami.infobase.dbstore",
"infogami.infobase.lru",
"infogami.infobase.readquery",
"infogami.infobase.writequery",
"infogami.utils.delegate", # required for monkey-patching
"infogami.utils.i18n",
"infogami.utils.storage",
]
suite = web.test.doctest_suite(modules)
web.test.runTests(suite)
@subcommand.subcommand()
def infobase(options=None, *args):
"""Test Infobase.
Options:
-d [--database] database : database name (default: test_infobase)
-u [--url] url : url of infobase to test; tested locally if not provided.
"""
print >> sys.stderr, "\nRunning infobase tests\n"
options = options or web.storage(database='test_infobase')
db = options.database or 'test_infobase'
web.config.test_url = options.__dict__.get('url')
web.config.debug = False
user=os.environ['USER']
web.config.db_parameters = dict(dbn='postgres', db=db, user=user, pw='')
from test import test_infobase
suite = web.test.module_suite(test_infobase, args or None)
web.test.runTests(suite)
@subcommand.subcommand()
def alltests(options=None):
"""Runn all tests."""
doctests([])
infobase([])
@subcommand.subcommand()
def schema(options=None):
"""Print db schema."""
from infogami.infobase import dbstore
print dbstore.Schema().sql()
if __name__ == "__main__":
subcommand.main()