summaryrefslogtreecommitdiff
path: root/example_project
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-01-29 16:44:30 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-07-01 18:01:59 +0200
commitb2670154ff81bdef1b7e4031712b85359fcb4e3b (patch)
tree608dcec7d25822ca25f864e682987503b94d2fc9 /example_project
parentad2a9a66bd3c9d9e81e7fb60ff4bf7ec99386cd3 (diff)
downloadIshtar-b2670154ff81bdef1b7e4031712b85359fcb4e3b.tar.bz2
Ishtar-b2670154ff81bdef1b7e4031712b85359fcb4e3b.zip
Tests with setup.py
Diffstat (limited to 'example_project')
-rw-r--r--example_project/local_settings.py.setup17
-rw-r--r--example_project/runtests.py41
2 files changed, 58 insertions, 0 deletions
diff --git a/example_project/local_settings.py.setup b/example_project/local_settings.py.setup
new file mode 100644
index 000000000..54dc99c4a
--- /dev/null
+++ b/example_project/local_settings.py.setup
@@ -0,0 +1,17 @@
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.contrib.gis.db.backends.postgis',
+ 'NAME': 'ishtar-test',
+ 'USER': 'ishtar-test',
+ 'PASSWORD': 'ishtar-test',
+ 'HOST': '',
+ 'PORT': '5432',
+ }
+}
+
+LOGFILE = '/tmp/ishtar.log'
+
+PROJECT_SLUG = "test-instance"
+
+SECRET_KEY = "not-so-secret-key"
+DISABLE_TASK_TIMEOUT = True
diff --git a/example_project/runtests.py b/example_project/runtests.py
new file mode 100644
index 000000000..633a94022
--- /dev/null
+++ b/example_project/runtests.py
@@ -0,0 +1,41 @@
+# run test for setup.py
+import os
+import shutil
+import sys
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'example_project.settings'
+test_dir = os.path.dirname(__file__)
+sys.path.insert(0, test_dir)
+local_settings = os.path.join(test_dir, "local_settings.py")
+local_settings_exists = True
+if not os.path.exists(local_settings):
+ local_settings_exists = False
+ shutil.copy(
+ os.path.join(test_dir, "local_settings.py.setup"),
+ local_settings)
+
+import django
+from django.test.utils import get_runner
+from django.conf import settings
+
+
+def runtests():
+ django.setup()
+ TestRunner = get_runner(settings)
+ test_runner = TestRunner(verbosity=1, interactive=True)
+ failures = test_runner.run_tests(
+ ["ishtar_common.tests",
+ "archaeological_files.tests",
+ "archaeological_operations.tests",
+ "archaeological_context_records.tests",
+ "archaeological_finds.tests",
+ "archaeological_warehouse.tests",
+ ]
+ )
+ if not local_settings_exists:
+ os.remove(local_settings)
+ sys.exit(failures)
+
+
+if __name__ == '__main__':
+ runtests()