From 9130160bd64f6ca45b33af592d842eee4c23820e Mon Sep 17 00:00:00 2001 From: "Philip Sargent (laptop)" Date: Thu, 13 May 2021 23:15:30 +0300 Subject: [PATCH] new tests for CAVERN and SURVEXPORT --- README.txt | 4 +++- core/TESTS/test_imports.py | 26 ++++++++++++++++++++++++++ pre-run.sh | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 1648966..b8fa85a 100644 --- a/README.txt +++ b/README.txt @@ -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 database. Sqlite3 is used by the test harness system. 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 dist-upgrade @@ -82,6 +83,7 @@ $ sudo apt install sqlite3 sqlite3-doc $ cd /usr/bin $ sudo ln -s python3 python $ sudo ln -s pip3 pip +$ sudo apt install survex Now install django etc. $ cd [troggle] diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py index 7445d25..54ea39c 100644 --- a/core/TESTS/test_imports.py +++ b/core/TESTS/test_imports.py @@ -20,12 +20,15 @@ https://docs.djangoproject.com/en/3.0/topics/testing/tools/ """ import unittest import re +import subprocess + from django.test import TestCase, SimpleTestCase, Client class SimpleTest(SimpleTestCase): def test_test_setting(self): from django.conf import settings self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend') + import troggle.settings as settings def test_import_TroggleModel(self): from troggle.core.models.troggle import TroggleModel 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.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') + diff --git a/pre-run.sh b/pre-run.sh index 53e3c1c..8f31bee 100755 --- a/pre-run.sh +++ b/pre-run.sh @@ -16,6 +16,7 @@ find . -name \*.py -print0 | xargs -0 egrep -vc "#|^\s*$" | grep -v ":0$" | gr python3 reset-django.py echo After cleanup deletion, remake all migrations. python3 manage.py makemigrations >/dev/null +python3 manage.py migrate python3 manage.py test python3 manage.py check -v 3 --deploy 2>security-warnings.txt >/dev/null python3 manage.py check -v 3 --deploy