-
Notifications
You must be signed in to change notification settings - Fork 16
/
run_tests.py
executable file
·88 lines (77 loc) · 2.85 KB
/
run_tests.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
import django, sys, os
from django.conf import settings
import argparse
from carrot.objects import VirtualHost
def runner(options):
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)
vhost = {
'host': options.host,
'port': options.port,
'name': options.name,
'username': options.username,
'password': options.password,
'secure': options.secure,
}
_vhost = VirtualHost(**vhost)
settings.configure(
DEBUG=True,
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'local',
}
},
ROOT_URLCONF='carrot.urls',
INSTALLED_APPS=(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.staticfiles',
'carrot',
),
CARROT={
'default_broker': str(_vhost),
'queues': [{
'name': 'default',
'host': str(_vhost),
}],
},
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
],
STATIC_URL='/static/',
)
django.setup()
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=0,)
failures = test_runner.run_tests(['carrot'])
if failures:
sys.exit(failures)
def main():
parser = argparse.ArgumentParser(description='Run the Carrot test suite')
parser.add_argument("-H", '--host', type=str, default='localhost', help='The RabbitMQ host')
parser.add_argument("-p", '--port', type=int, default=5672, help='The port number')
parser.add_argument("-n", '--name', type=str, default='/', help='The virtual host name')
parser.add_argument("-U", '--username', type=str, default='guest', help='Your RabbitMQ username')
parser.add_argument("-P", '--password', type=str, default='guest', help='Your RabbitMQ password')
parser.set_defaults(secure=False)
parser.add_argument('-s', '--secure', dest='secure', action='store_true', default=False,
help='Connect to RabbitMQ host over HTTPS')
args = parser.parse_args()
runner(args)
if __name__ == '__main__':
main()