Skip to content

Commit 39bf6e0

Browse files
committed
Adding test settings for more easily running tests
1 parent 81f0dfb commit 39bf6e0

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ libraries.
150150
Use a code editor that integrates with editorconfig and flake8. I also recommend
151151
autopep8 for automatically formatting code to follow the PEP8 guidelines.
152152
153+
### Running Django Tests
154+
155+
Run `./runtests.py` to run the Django unit tests.
156+
153157
## License
154158
155159
The Apache Airavata Django Portal is licensed under the Apache 2.0 license. For

runtests.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
# This script based on
3+
# https://docs.djangoproject.com/en/1.11/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
4+
import os
5+
import sys
6+
7+
import django
8+
from django.conf import settings
9+
from django.test.utils import get_runner
10+
11+
if __name__ == "__main__":
12+
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
13+
django.setup()
14+
TestRunner = get_runner(settings)
15+
test_runner = TestRunner()
16+
# Pass None for test_labels to have the runner discover all tests under
17+
# this directory
18+
failures = test_runner.run_tests(None)
19+
sys.exit(bool(failures))

tests/__init__.py

Whitespace-only changes.

tests/settings.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
3+
# Import the common settings, can override them below as needed
4+
from django_airavata.settings import *
5+
6+
BASEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7+
8+
# Use a SQLite database for testing
9+
DATABASES = {
10+
'default': {
11+
'ENGINE': 'django.db.backends.sqlite3',
12+
'NAME': os.path.join(BASEDIR, 'db.sqlite3'),
13+
}
14+
}
15+
16+
# Settings that are expected to be defined in settings_local.py
17+
AIRAVATA_API_HOST = 'localhost'
18+
AIRAVATA_API_PORT = 8930
19+
AIRAVATA_API_SECURE = False
20+
21+
PROFILE_SERVICE_HOST = AIRAVATA_API_HOST
22+
PROFILE_SERVICE_PORT = 8962
23+
PROFILE_SERVICE_SECURE = False
24+
25+
SHARING_API_HOST = AIRAVATA_API_HOST
26+
SHARING_API_PORT = 7878
27+
SHARING_API_SECURE = False
28+
29+
PORTAL_TITLE = 'Django Airavata Gateway'

0 commit comments

Comments
 (0)