-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.py
50 lines (35 loc) · 1.33 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
from __future__ import unicode_literals, absolute_import
import os
import sys
import django
from django.core import management
from django.conf import settings
from django.test.utils import get_runner
from datetime import datetime
here = os.path.dirname(os.path.abspath(__file__))
def run_tests(*test_args):
if not test_args:
test_args = ["tests"]
testing_db = os.path.join(here, "test-db.sqlite")
# Testing DB
if os.path.exists(testing_db):
os.remove(testing_db)
# Set environment variables
os.environ["DJANGO_SETTINGS_MODULE"] = "spackmon.settings"
os.environ["SECRET_KEY"] = "youarethetacomaster"
os.environ["JWT_SERVER_SECRET"] = "youarethetacomaster"
os.environ["CREATION_DATE"] = str(datetime.now())
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
# Prepare databases and server
management.call_command("makemigrations", "main", verbosity=1)
management.call_command("makemigrations", "users", verbosity=1)
management.call_command("makemigrations", "admin", verbosity=1)
management.call_command("migrate", verbosity=1)
test_runner.setup_databases()
failures = test_runner.run_tests(test_args)
# test_runner.teardown_test_environment()
sys.exit(bool(failures))
if __name__ == "__main__":
run_tests(*sys.argv[1:])