From 3a16e77bef7d0d2c443bb767c5aab4ca32653636 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 1 Dec 2021 20:24:34 +0000 Subject: [PATCH] Correct page on testing --- handbook/computing/contribute.html | 2 +- handbook/troggle/trogindex.html | 4 +- handbook/troggle/trognotes.html | 2 +- handbook/troggle/trogtests.html | 72 ++++++++++++++++++++++++++++++ handbook/troggle/unittests.html | 48 -------------------- 5 files changed, 76 insertions(+), 52 deletions(-) create mode 100644 handbook/troggle/trogtests.html delete mode 100644 handbook/troggle/unittests.html diff --git a/handbook/computing/contribute.html b/handbook/computing/contribute.html index af51e6151..4e72d0341 100644 --- a/handbook/computing/contribute.html +++ b/handbook/computing/contribute.html @@ -146,7 +146,7 @@ you can contribute to fixing things in the Expo Systems< If you really want to get stuck into the code you will need a troggle software development configuration.

Finally, if that all sounds like too much hassle for you, were are in desparate need -of a lot more very simple unit tests for troggle. +of a lot more very simple tests for troggle. The more tests we have, the more confident we can be about making big changes without breaking things. We especially need these for the input parsers as whatever happens in the future, we are still going to need to parse the archived input files. diff --git a/handbook/troggle/trogindex.html b/handbook/troggle/trogindex.html index 22fc8ae62..f8afc2ca0 100644 --- a/handbook/troggle/trogindex.html +++ b/handbook/troggle/trogindex.html @@ -36,7 +36,7 @@ Troggle and Django - The Django web framework we use
Troggle: updating Django - Upgrading troggle to use a later Django version
-Troggle unit tests - test suite for programmers
+Troggle tests - test suite for programmers
Troggle & expo systems - status update - where we are now

@@ -48,7 +48,7 @@


diff --git a/handbook/troggle/trognotes.html b/handbook/troggle/trognotes.html index c6e9f9a49..4aa7013d0 100644 --- a/handbook/troggle/trognotes.html +++ b/handbook/troggle/trognotes.html @@ -82,7 +82,7 @@ to get involved in the progra

Running the test suite

This manual is very incomplete - notes

diff --git a/handbook/troggle/trogtests.html b/handbook/troggle/trogtests.html new file mode 100644 index 000000000..33ddc0251 --- /dev/null +++ b/handbook/troggle/trogtests.html @@ -0,0 +1,72 @@ + + + + +Handbook Troggle - Automated Testing + + + +

CUCC Expedition Handbook

+

Handbook Troggle - Automated Testing

+ +

Troggle Automated Testing

+

We have a suite of more than 70 smoke tests +which are run manually by troggle programmers like this: +

 troggle$ python manage.py test -v 1
+ +

These are 'end to end' tests which very quickly show whether something is badly broken. The tests are for two purposes only: +

+

This is surprisingly effective. Django produces excellently detailed tracebacks when an fault happens, +which allow us to home in on the precise part of the code which has been broken by a version upgrade. +

We do also have a handful of unit tests which just poke data into the database and check that it can be read out again. +

+The test code is all in troggle/core/TESTS/. +

Example test

+

The test 'test_page_expofile' checks that a particular PDF is being served correctly by the web server +and that the resulting page is the correct length of 2,299,270 bytes: + +


+    def test_page_expofile(self):
+        # Flat file tests.
+        response = self.client.get('/expofiles/documents/surveying/tunnel-loefflerCP35-only.pdf')
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(len(response.content), 2299270)
+
+ +

Django test system

+

This test suite uses the the +django test system. One of the things this does +is to ensure that all the settings are imported correctly and makes it easy to specify a test as an input URL and expected +HTML output using a Django object text client. +It sets up a very fast in-memory sqlite database purely for tests. +No tests are run with the real expo database. + +

Troggle tests

+

The tests can be run at a more verbose level by setting the -v 3 flag. + +

As yet we have no test database set up, so the in-memory database starts entirely empty. However we have 'fixtures' in +troggle/core/fixtures/ +which are JSON files containing dummy data which is read in before a few of the tests. + +

Automated testing on the server

+

Something is stopping the test suite running on the server. We haven't fixed this yet. + +

How you can help

+

We could do with a lot more unit tests which test small, specific things. If we have a lot of these it will make future re-engineering of troggle easier, as we can more confidently tackle big re-writes and still be sure that nothing is broken. +

We haven't got any tests which check that the input parsers work. None. + +

Have a look at Wikpedia's review of types of software testing for ideas. +

If you want to write some tests and are having trouble finding something which is untested, have a look at the list of +url paths in the routing system in troggle/urls.py +and look for types of url which do not appear in the test suite checks. + +


+Go on to: Troggle architecture
+Return to: Troggle intro
+Troggle index: +Index of all troggle documents

+ + diff --git a/handbook/troggle/unittests.html b/handbook/troggle/unittests.html deleted file mode 100644 index 2153fafa8..000000000 --- a/handbook/troggle/unittests.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Handbook Troggle - Unit Tests - - - -

CUCC Expedition Handbook

-

Handbook Troggle - Unit Tests

- -

Troggle Unit Tests

-

We have a small suite of tests which are run manually by troggle programmers like this: -

 troggle$ python manage.py test -v 1
-The test code is all in troggle/core/TESTS/tests.py. -

The test 'test_page_expofile' checks that a particular PDF is being served correctly by the web server -and that the resulting page is the correct length of 2,299,270 bytes: - -


-    def test_page_expofile(self):
-        # Flat file tests.
-        response = self.client.get('/expofiles/documents/surveying/tunnel-loefflerCP35-only.pdf')
-        self.assertEqual(response.status_code, 200)
-        self.assertEqual(len(response.content), 2299270)
-
- -

This test suite is part of the -django test system which is a very thin layer on top of the standard python library module -unittest. One of the things this layer does -is to ensure that all the settings are imported correctly, and it sets up a very fast in-memory sqlite database purely for tests. -No tests are run with the real expo database. -

The tests can be run at a more verbose level by setting the -v 3 flag. - -

As yet we have no test database set up, so the in-memory database is entirely empty. However we have 'fixtures' in -troggle/core/fixtures/ -which are JSON files containing dummy data which is used in the more complex tests. - -

If you want to write some tests and are having trouble finding something which is untested, have a look at the list of -url paths in the routing system in troggle/urls.py -and look for types of url which do not appear in the test suite checks. - -


-Go on to: Troggle architecture
-Return to: Troggle intro
-Troggle index: -Index of all troggle documents

- -