-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathruntests.py
64 lines (49 loc) · 1.61 KB
/
runtests.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
import os
import sys
import django
from django.conf import settings
from django.contrib.auth import get_user_model
sys.path.append(os.path.abspath('./src'))
def _get_user_from_token_info(token_info):
user, _ = get_user_model().objects.get_or_create(u_idx=token_info.u_idx)
return user
SETTINGS_DICT = {
'DEBUG': True,
'USE_TZ': True,
'DATABASES': {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'
}
},
'AUTH_USER_MODEL': 'ridi_django_oauth2.RidiUser',
'INSTALLED_APPS': [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sites',
'ridi_django_oauth2',
'tests',
],
'MIDDLEWARE_CLASSES': (
'ridi_django_oauth2.middlewares.AuthenticationMiddleware',
),
'RIDI_ridi_oauth2_ID': 'dummy_client_id',
'RIDI_ridi_oauth2_SECRET': 'dummy_client_secret',
'RIDI_OAUTH2_AUTHORIZATION_URL': 'http://localhost/oauth2/authorize/',
'RIDI_OAUTH2_TOKEN_URL': 'http://localhost/oauth2/token/',
'RIDI_OAUTH2_KEY_URL': 'https://account.dev.ridi.io/oauth2/keys/public',
'RIDI_OAUTH2_GET_USER_FROM_TOKEN_INFO': _get_user_from_token_info
}
def run_tests(*test_args):
if not test_args:
test_args = ['tests']
settings.configure(**SETTINGS_DICT)
django.setup()
# Run tests
from django.test.utils import get_runner
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(test_args, interactive=False)
sys.exit(bool(failures))
if __name__ == '__main__':
run_tests(*sys.argv[1:])