|
a/AlluraTesting/alluratest/controller.py |
|
b/AlluraTesting/alluratest/controller.py |
|
... |
|
... |
42 |
#from allura.lib.custom_middleware import environ as ENV, MagicalC
|
42 |
#from allura.lib.custom_middleware import environ as ENV, MagicalC
|
43 |
from .validation import ValidatingTestApp
|
43 |
from .validation import ValidatingTestApp
|
44 |
|
44 |
|
45 |
DFL_APP_NAME = 'main_without_authn'
|
45 |
DFL_APP_NAME = 'main_without_authn'
|
46 |
|
46 |
|
|
|
47 |
# these are all helpers & base classes, and should never
|
|
|
48 |
# be considered test cases when imported into some test module
|
|
|
49 |
__test__ = False
|
|
|
50 |
|
|
|
51 |
|
47 |
def get_config_file(config=None):
|
52 |
def get_config_file(config=None):
|
48 |
if not config:
|
53 |
if not config:
|
49 |
config = 'test.ini'
|
54 |
config = 'test.ini'
|
50 |
|
55 |
|
51 |
try:
|
56 |
try:
|
52 |
conf_dir = tg.config.here
|
57 |
conf_dir = tg.config.here
|
53 |
except AttributeError:
|
58 |
except AttributeError:
|
54 |
conf_dir = os.getcwd()
|
59 |
conf_dir = os.getcwd()
|
55 |
return os.path.join(conf_dir, config)
|
60 |
return os.path.join(conf_dir, config)
|
|
|
61 |
|
56 |
|
62 |
|
57 |
def setup_basic_test(config=None, app_name=DFL_APP_NAME):
|
63 |
def setup_basic_test(config=None, app_name=DFL_APP_NAME):
|
58 |
'''Create clean environment for running tests'''
|
64 |
'''Create clean environment for running tests'''
|
59 |
try:
|
65 |
try:
|
60 |
conf_dir = tg.config.here
|
66 |
conf_dir = tg.config.here
|
|
... |
|
... |
66 |
cmd.run([test_file])
|
72 |
cmd.run([test_file])
|
67 |
|
73 |
|
68 |
# run all tasks, e.g. indexing from bootstrap operations
|
74 |
# run all tasks, e.g. indexing from bootstrap operations
|
69 |
while M.MonQTask.run_ready('setup'):
|
75 |
while M.MonQTask.run_ready('setup'):
|
70 |
ThreadLocalORMSession.flush_all()
|
76 |
ThreadLocalORMSession.flush_all()
|
|
|
77 |
setup_basic_test.__test__ = False # sometimes __test__ above isn't sufficient
|
|
|
78 |
|
71 |
|
79 |
|
72 |
def setup_functional_test(config=None, app_name=DFL_APP_NAME):
|
80 |
def setup_functional_test(config=None, app_name=DFL_APP_NAME):
|
73 |
'''Create clean environment for running tests. Also return WSGI test app'''
|
81 |
'''Create clean environment for running tests. Also return WSGI test app'''
|
74 |
config = get_config_file(config)
|
82 |
config = get_config_file(config)
|
75 |
setup_basic_test(config, app_name)
|
83 |
setup_basic_test(config, app_name)
|
76 |
conf_dir = tg.config.here
|
84 |
conf_dir = tg.config.here
|
77 |
wsgiapp = loadapp('config:%s#%s' % (config, app_name),
|
85 |
wsgiapp = loadapp('config:%s#%s' % (config, app_name),
|
78 |
relative_to=conf_dir)
|
86 |
relative_to=conf_dir)
|
79 |
return wsgiapp
|
87 |
return wsgiapp
|
|
|
88 |
setup_functional_test.__test__ = False # sometimes __test__ above isn't sufficient
|
|
|
89 |
|
80 |
|
90 |
|
81 |
def setup_unit_test():
|
91 |
def setup_unit_test():
|
82 |
try:
|
92 |
try:
|
83 |
while True:
|
93 |
while True:
|
84 |
REGISTRY.cleanup()
|
94 |
REGISTRY.cleanup()
|
|
... |
|
... |
95 |
REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
|
105 |
REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
|
96 |
c.memoize_cache = {}
|
106 |
c.memoize_cache = {}
|
97 |
c.queued_messages = None
|
107 |
c.queued_messages = None
|
98 |
c.model_cache = None
|
108 |
c.model_cache = None
|
99 |
ThreadLocalORMSession.close_all()
|
109 |
ThreadLocalORMSession.close_all()
|
|
|
110 |
setup_unit_test.__test__ = False # sometimes __test__ above isn't sufficient
|
|
|
111 |
|
100 |
|
112 |
|
101 |
def setup_global_objects():
|
113 |
def setup_global_objects():
|
102 |
setup_unit_test()
|
114 |
setup_unit_test()
|
103 |
h.set_context('test', 'wiki', neighborhood='Projects')
|
115 |
h.set_context('test', 'wiki', neighborhood='Projects')
|
104 |
c.user = M.User.query.get(username='test-admin')
|
116 |
c.user = M.User.query.get(username='test-admin')
|