summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-06-03 21:57:05 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-06-03 21:57:05 +0100
commitae89a707ece67bc89eb165d86aaf46e55411eb3f (patch)
tree02868da821556b3b715cea71fd5cd1c8fd6a739e
parent973c6f4ef81edaa7526932f2a914d37f62590126 (diff)
downloadtroggle-ae89a707ece67bc89eb165d86aaf46e55411eb3f.tar.gz
troggle-ae89a707ece67bc89eb165d86aaf46e55411eb3f.tar.bz2
troggle-ae89a707ece67bc89eb165d86aaf46e55411eb3f.zip
Unit tests outline implemented
-rw-r--r--core/TESTS/__init__.py0
-rw-r--r--core/TESTS/tests.py62
-rw-r--r--databaseReset.py17
-rw-r--r--flatpages/tests.py23
4 files changed, 73 insertions, 29 deletions
diff --git a/core/TESTS/__init__.py b/core/TESTS/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/core/TESTS/__init__.py
diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py
new file mode 100644
index 0000000..aa92210
--- /dev/null
+++ b/core/TESTS/tests.py
@@ -0,0 +1,62 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+
+https://docs.python.org/3.8/library/doctest.html
+
+https://docs.djangoproject.com/en/3.0/topics/testing/tools/
+"""
+
+from django.test import TestCase, SimpleTestCase
+
+class SimpleTest(SimpleTestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
+ def test_import_TroggleModel(self):
+ from troggle.core.models import TroggleModel
+ def test_import_Cave(self):
+ from troggle.core.models_caves import Cave
+ def test_import_parsers_surveys(self):
+ from PIL import Image
+ from utils import save_carefully
+ from functools import reduce
+ def test_import_parsers_survex(self):
+ import troggle.settings as settings
+ import troggle.core.models as models
+ import troggle.core.models_caves as models_caves
+ import troggle.core.models_survex as models_survex
+ from troggle.parsers.people import GetPersonExpeditionNameLookup
+ from troggle.core.views_caves import MapLocations
+ def test_import_parsers_QMs(self):
+ from troggle.core.models_caves import QM, Cave, LogbookEntry
+ from utils import save_carefully
+ def test_import_parsers_people(self):
+ from html.parser import HTMLParser
+ from unidecode import unidecode
+ def test_import_parsers_logbooks(self):
+ from django.template.defaultfilters import slugify
+ from django.utils.timezone import get_current_timezone, make_aware
+ from troggle.core.models import DataIssue, Expedition
+ from troggle.core.models_caves import Cave, OtherCaveName, getCaveByReference, LogbookEntry, PersonTrip
+ from parsers.people import GetPersonExpeditionNameLookup
+ def test_import_core_views_caves(self):
+ from django.http import HttpResponse, HttpResponseRedirect
+ from django.shortcuts import get_object_or_404, render
+ from troggle.core.models import Expedition
+ from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, Survey, QM, CaveDescription, EntranceSlug, Entrance, Area, SurvexStation
+ from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
+ from troggle.helper import login_required_if_public
+
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
diff --git a/databaseReset.py b/databaseReset.py
index 31ea102..2319827 100644
--- a/databaseReset.py
+++ b/databaseReset.py
@@ -32,6 +32,9 @@ expouser=settings.EXPOUSER
expouserpass=settings.EXPOUSERPASS
expouseremail=settings.EXPOUSER_EMAIL
+def call_django_tests(n):
+ management.call_command('test', verbosity=n)
+
def reinit_db():
"""Rebuild database from scratch. Deletes the file first if sqlite is used,
otherwise it drops the database and creates it.
@@ -89,6 +92,11 @@ def import_QMs():
print("Importing QMs (old caves)")
import troggle.parsers.QMs
# import process itself runs on qm.csv in only 3 old caves, not the modern ones!
+
+def import_surveyscans():
+ import troggle.parsers.surveys
+ print("Importing Survey Scans")
+ troggle.parsers.surveys.LoadListScans()
def import_survexblks():
import troggle.parsers.survex
@@ -108,11 +116,6 @@ def import_surveyimgs():
print("NOT Importing survey images")
#troggle.parsers.surveys.parseSurveys(logfile=settings.LOGFILE)
-def import_surveyscans():
- import troggle.parsers.surveys
- print("Importing Survey Scans")
- troggle.parsers.surveys.LoadListScans()
-
def import_tunnelfiles():
import troggle.parsers.surveys
print("Importing Tunnel files")
@@ -415,13 +418,15 @@ if __name__ == "__main__":
runlabel = sys.argv[len(sys.argv)-1]
else:
runlabel=None
-
+
+ call_django_tests(1)
jq = JobQueue(runlabel)
if len(sys.argv)==1:
usage()
exit()
elif "test" in sys.argv:
+ call_django_tests(2)
jq.enq("caves",import_caves)
jq.enq("people",import_people)
elif "caves" in sys.argv:
diff --git a/flatpages/tests.py b/flatpages/tests.py
deleted file mode 100644
index c7c4668..0000000
--- a/flatpages/tests.py
+++ /dev/null
@@ -1,23 +0,0 @@
-"""
-This file demonstrates two different styles of tests (one doctest and one
-unittest). These will both pass when you run "manage.py test".
-
-Replace these with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.assertEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
-
->>> 1 + 1 == 2
-True
-"""}
-