Skip to content

Commit 5fc5ba5

Browse files
test: add missing test configuration
1 parent 042ba34 commit 5fc5ba5

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ Change Log
66
in this file. It adheres to the structure of https://keepachangelog.com/ ,
77
but in reStructuredText instead of Markdown (for ease of incorporation into
88
Sphinx documentation and the PyPI description).
9-
9+
1010
This project adheres to Semantic Versioning (https://semver.org/).
1111

1212
.. There should always be an "Unreleased" section for changes pending release.
1313
1414
Unreleased
1515
~~~~~~~~~~
1616

17-
*
17+
* Add Django testing configuration.
1818

1919
[0.1.0] - 2021-04-07
2020
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

manage.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
"""
3+
Django administration utility.
4+
"""
5+
6+
import os
7+
import sys
8+
9+
PWD = os.path.abspath(os.path.dirname(__file__))
10+
11+
if __name__ == '__main__':
12+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_utils.test_settings')
13+
sys.path.append(PWD)

test_utils/test_settings.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
These settings are here to use during tests, because django requires them.
3+
In a real-world use case, apps in this project are installed into other
4+
Django applications, so these settings will not be used.
5+
"""
6+
7+
DATABASES = {
8+
"default": {
9+
"ENGINE": "django.db.backends.sqlite3",
10+
"NAME": "default.db",
11+
"USER": "",
12+
"PASSWORD": "",
13+
"HOST": "",
14+
"PORT": "",
15+
},
16+
"read_replica": {
17+
"ENGINE": "django.db.backends.sqlite3",
18+
"NAME": "read_replica.db",
19+
"USER": "",
20+
"PASSWORD": "",
21+
"HOST": "",
22+
"PORT": "",
23+
},
24+
}
25+
26+
27+
INSTALLED_APPS = (
28+
"openedx_events",
29+
)
30+
31+
SECRET_KEY = "not-so-secret-key"

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ignore = D101,D200,D203,D212,D215,D404,D405,D406,D407,D408,D409,D410,D411,D412,D
3232

3333

3434
[pytest]
35+
DJANGO_SETTINGS_MODULE = test_utils.test_settings
3536
addopts = --cov openedx_events --cov-report term-missing --cov-report xml
3637
norecursedirs = .* docs requirements site-packages
3738

@@ -43,6 +44,7 @@ commands =
4344

4445
[testenv:docs]
4546
setenv =
47+
DJANGO_SETTINGS_MODULE = test_utils.test_settings
4648
PYTHONPATH = {toxinidir}
4749
whitelist_externals =
4850
make
@@ -69,7 +71,7 @@ commands =
6971

7072
[testenv:pii_check]
7173
setenv =
72-
DJANGO_SETTINGS_MODULE = test_settings
74+
DJANGO_SETTINGS_MODULE = test_utils.test_settings
7375
deps =
7476
-r{toxinidir}/requirements/test.txt
7577
commands =

0 commit comments

Comments
 (0)