-
Notifications
You must be signed in to change notification settings - Fork 21
/
test.py
executable file
·93 lines (79 loc) · 2.9 KB
/
test.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
import unittest
from torndb import Connection
from tornado.options import options
from tornado.httpclient import AsyncHTTPClient
import MySQLdb
import mltshpoptions
from settings import test_settings
# If test.AccountTests fails to import, it should fail loudly...
import test.AccountTests
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
TEST_MODULES = [
'test.AccountTests',
'test.CommentTests',
'test.ExternalAccountTests',
'test.FileTests',
'test.SimpleTests',
'test.SiteFunctionTests',
'test.unit.app_tests',
'test.unit.comment_tests',
'test.unit.externalservice_tests',
'test.unit.notification_tests',
'test.unit.shake_tests',
'test.unit.sharedfile_tests',
'test.unit.sourcefile_tests',
'test.unit.task_tests',
'test.unit.user_tests',
'test.unit.conversation_tests',
'test.unit.external_relationship_tests',
'test.unit.bookmark_tests',
'test.unit.fileview_tests',
'test.unit.script_log_tests',
'test.functional.account_tests',
'test.functional.account_settings_tests',
'test.functional.admin_user_tests',
'test.functional.conversations_tests',
'test.functional.error_tests',
'test.functional.image_like_tests',
'test.functional.image_nsfw_tests',
'test.functional.image_comment_tests',
'test.functional.invite_member_tests',
'test.functional.misc_tests',
'test.functional.payments_tests',
'test.functional.request_invitation_tests',
'test.functional.shake_crud_tests',
'test.functional.tools_find_people_tests',
'test.functional.image_save_tests',
'test.functional.invite_member_tests',
'test.functional.home_tests',
'test.functional.create_account_tests',
'test.functional.verify_email_tests',
'test.functional.api_tests',
'test.functional.voucher_tests',
'test.scripts.calculate_views_tests',
]
def all():
return unittest.defaultTestLoader.loadTestsFromNames(TEST_MODULES)
if __name__ == '__main__':
mltshpoptions.parse_dictionary(test_settings)
import tornado.testing
db = Connection(options.database_host, 'mysql', options.database_user, options.database_password)
try:
db.execute("CREATE database %s" % options.database_name)
except MySQLdb.ProgrammingError, exc:
if exc.args[0] != 1007: # database already exists
raise
else:
with open("setup/db-install.sql") as f:
load_query = f.read()
db.execute("USE %s" % options.database_name)
statements = load_query.split(";")
for statement in statements:
# Utilize in-memory tables for faster tests.
# Note there are some differences here with InnoDB, but
# they shouldn't materially affect our tests.
cmd = statement.replace("InnoDB", "MEMORY").strip()
if cmd != "":
db.execute(cmd)
tornado.testing.main()