2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

new tests for CAVERN and SURVEXPORT

This commit is contained in:
Philip Sargent 2021-05-13 23:15:30 +03:00
parent 6410cc1090
commit 9130160bd6
3 changed files with 30 additions and 1 deletions

View File

@ -72,7 +72,8 @@ Install Django using pip, not with apt, on your test system.
You will also definitely need sqlite3 even if you are planning to use another You will also definitely need sqlite3 even if you are planning to use another
database. Sqlite3 is used by the test harness system. database. Sqlite3 is used by the test harness system.
Your Linux installation almost certainly already includes python3 and pip3 but Your Linux installation almost certainly already includes python3 and pip3 but
in case it doesn't install those like this: in case it doesn't install those.
You also need survex - which installs a shedload of other packages.
$ sudo apt update $ sudo apt update
$ sudo apt dist-upgrade $ sudo apt dist-upgrade
@ -82,6 +83,7 @@ $ sudo apt install sqlite3 sqlite3-doc
$ cd /usr/bin $ cd /usr/bin
$ sudo ln -s python3 python $ sudo ln -s python3 python
$ sudo ln -s pip3 pip $ sudo ln -s pip3 pip
$ sudo apt install survex
Now install django etc. Now install django etc.
$ cd [troggle] $ cd [troggle]

View File

@ -20,12 +20,15 @@ https://docs.djangoproject.com/en/3.0/topics/testing/tools/
""" """
import unittest import unittest
import re import re
import subprocess
from django.test import TestCase, SimpleTestCase, Client from django.test import TestCase, SimpleTestCase, Client
class SimpleTest(SimpleTestCase): class SimpleTest(SimpleTestCase):
def test_test_setting(self): def test_test_setting(self):
from django.conf import settings from django.conf import settings
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend') self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
import troggle.settings as settings
def test_import_TroggleModel(self): def test_import_TroggleModel(self):
from troggle.core.models.troggle import TroggleModel from troggle.core.models.troggle import TroggleModel
def test_import_Cave(self): def test_import_Cave(self):
@ -105,5 +108,28 @@ class SimpleTest(SimpleTestCase):
from troggle.core.views.statistics import pathsreport, stats, dataissues from troggle.core.views.statistics import pathsreport, stats, dataissues
from troggle.core.views.survex import survexcaveslist, survexcavesingle, svx from troggle.core.views.survex import survexcaveslist, survexcavesingle, svx
class SubprocessTest(TestCase):
@classmethod
def setUpTestData(cls):
pass
def setUp(self):
pass
def tearDown(self):
pass
def test_installs(self):
import troggle.settings as settings
for i in [settings.CAVERN, settings.SURVEXPORT]:
# Define command as string and then split() into list format
cmd = f'which {i}'.split()
try:
sp = subprocess.check_call(cmd, shell=False)
except subprocess.CalledProcessError:
self.assertTrue( False, f'no {i} installed')

View File

@ -16,6 +16,7 @@ find . -name \*.py -print0 | xargs -0 egrep -vc "#|^\s*$" | grep -v ":0$" | gr
python3 reset-django.py python3 reset-django.py
echo After cleanup deletion, remake all migrations. echo After cleanup deletion, remake all migrations.
python3 manage.py makemigrations >/dev/null python3 manage.py makemigrations >/dev/null
python3 manage.py migrate
python3 manage.py test python3 manage.py test
python3 manage.py check -v 3 --deploy 2>security-warnings.txt >/dev/null python3 manage.py check -v 3 --deploy 2>security-warnings.txt >/dev/null
python3 manage.py check -v 3 --deploy python3 manage.py check -v 3 --deploy