Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add missing configuration for testing #3

Merged
merged 1 commit into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
contain the root `toctree` directive.

openedx-filters
==============
===============

What is this project?

Expand Down
29 changes: 29 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python
"""
Django administration utility.
"""

import os
import sys

PWD = os.path.abspath(os.path.dirname(__file__))

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_utils.test_settings')
sys.path.append(PWD)
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django # pylint: disable=unused-import
except ImportError as error:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from error
raise
execute_from_command_line(sys.argv)
31 changes: 31 additions & 0 deletions test_utils/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

"""
These settings are here to use during tests, because django requires them.

In a real-world use case, apps in this project are installed into other
Django applications, so these settings will not be used.
"""

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "default.db",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
},
"read_replica": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "read_replica.db",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
},
}


INSTALLED_APPS = (
"openedx_filters",
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

"""
Tests for openedx_filters.py.
"""
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ignore = D101,D200,D203,D212,D215,D404,D405,D406,D407,D408,D409,D410,D411,D412,D


[pytest]
DJANGO_SETTINGS_MODULE = test_utils.test_settings
addopts = --cov openedx_filters --cov-report term-missing --cov-report xml
norecursedirs = .* docs requirements site-packages

Expand All @@ -43,6 +44,7 @@ commands =

[testenv:docs]
setenv =
DJANGO_SETTINGS_MODULE = test_utils.test_settings
PYTHONPATH = {toxinidir}
whitelist_externals =
make
Expand All @@ -69,7 +71,7 @@ commands =

[testenv:pii_check]
setenv =
DJANGO_SETTINGS_MODULE = test_settings
DJANGO_SETTINGS_MODULE = test_utils.test_settings
deps =
-r{toxinidir}/requirements/test.txt
commands =
Expand Down