Skip to content
Snippets Groups Projects
Commit 89ad0194 authored by Hervé Ménager's avatar Hervé Ménager
Browse files

scripts to bootstrap django and test code

parent 4d24916a
Branches
No related tags found
No related merge requests found
# boot_django.py
#
# This file sets up and configures Django. It's used by scripts that need to
# execute as if running in a Django server.
import os
import django
from django.conf import settings
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "biodblinks"))
def boot_django():
settings.configure(
BASE_DIR=BASE_DIR,
DEBUG=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
},
INSTALLED_APPS=("biodblinks",),
TIME_ZONE="UTC",
USE_TZ=True,
LABLINKS_ID_PREFIX="https://django-biodblinks.pasteur.fr",
LABLINKS_PROVIDER_ID="1111",
LABLINKS_RESOURCE_NAME="django-biodblinks foo DB",
LABLINKS_RESOURCE_DESCRIPTION="django-biodblinks foo DB: a non-existent database that should not be linked to",
LABLINKS_CONTACT_EMAIL="noreply@pasteur.fr",
)
django.setup()
#!/usr/bin/env python
# load_tests.py
import sys
from unittest import TestSuite
from boot_django import boot_django
boot_django()
default_labels = [
"biodblinks.tests",
]
def get_suite(labels=default_labels):
from django.test.runner import DiscoverRunner
runner = DiscoverRunner(verbosity=1)
failures = runner.run_tests(labels)
if failures:
sys.exit(failures)
# In case this is called from setuptools, return a test suite
return TestSuite()
if __name__ == "__main__":
labels = default_labels
if len(sys.argv[1:]) > 0:
labels = sys.argv[1:]
get_suite(labels)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment