forked from jamstooks/django-membersuite-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·84 lines (64 loc) · 2.48 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
#!/usr/bin/env python
import os
import sys
import django
BASE_PATH = os.path.dirname(__file__)
def main():
"""Standalone django model test with a
'memory-only-django-installation'. You can play with a django
model without a complete django app installation.
http://www.djangosnippets.org/snippets/1044/
"""
os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
from django.conf import global_settings
global_settings.USE_TZ = True
global_settings.STATIC_URL = os.environ.get('STATIC_URL', '/static/')
global_settings.STATIC_ROOT = os.environ.get(
'STATIC_ROOT',
os.path.join(BASE_PATH, global_settings.STATIC_URL.strip('/')))
global_settings.INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django_membersuite_auth'
)
global_settings.DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_PATH,
'django-membersuite-auth.sqlite'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
global_settings.MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
global_settings.SECRET_KEY = "blahblah"
global_settings.SITE_ID = 1
global_settings.MS_ACCESS_KEY = os.environ["MS_ACCESS_KEY"]
global_settings.MS_SECRET_KEY = os.environ["MS_SECRET_KEY"]
global_settings.MS_ASSOCIATION_ID = os.environ["MS_ASSOCIATION_ID"]
global_settings.AUTH_USER_MODEL = "auth.User"
from django.test.utils import get_runner
test_runner = get_runner(global_settings)
try:
django.setup()
except AttributeError:
pass
test_runner = test_runner()
test_labels = (sys.argv[1:] if len(sys.argv) > 1
else ["django_membersuite_auth"])
failures = test_runner.run_tests(test_labels)
sys.exit(failures)
if __name__ == '__main__':
main()