diff --git a/boot_django.py b/boot_django.py new file mode 100644 index 0000000000000000000000000000000000000000..800f1b7ac759e48da1db5cca5e8892ffeba9c916 --- /dev/null +++ b/boot_django.py @@ -0,0 +1,40 @@ +# 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() diff --git a/load_tests.py b/load_tests.py new file mode 100644 index 0000000000000000000000000000000000000000..4decb960a317b2d4b20df9682f0aaee5cc903de4 --- /dev/null +++ b/load_tests.py @@ -0,0 +1,45 @@ +#!/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)