mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-26 17:21:55 +00:00
43 lines
2.1 KiB
HTML
43 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Handbook Troggle - Unit Tests</title>
|
|
<link rel="stylesheet" type="text/css" href="../../css/main2.css" />
|
|
</head>
|
|
<body><style>body { background: #fff url(/images/style/bg-system.png) repeat-x 0 0 }</style>
|
|
<h2 id="tophead">CUCC Expedition Handbook</h2>
|
|
<h1>Handbook Troggle - Unit Tests</h1>
|
|
|
|
<h2>Troggle Unit Tests</h2>
|
|
<p>We have a small suite of tests which are run manually by troggle programmers like this:
|
|
<pre><code> troggle$ python manage.py tests -v 1</code></pre>
|
|
The test code is all in <a href="http://expo.survex.com/repositories/troggle/.git/tree/core/TESTS/tests.py"><var>troggle/core/TESTS/tests.py</var></a>.
|
|
<p>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:
|
|
|
|
<pre><code>
|
|
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)
|
|
</code></pre>
|
|
|
|
<p>This test suite is part of <a href="https://docs.djangoproject.com/en/1.11/topics/testing/">the
|
|
django test system</a> which is a very thin layer on top of the standard python library module
|
|
<a href="https://docs.python.org/3/library/unittest.html#module-unittest">unittest</a>. 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.
|
|
<p>The tests can be run at a more verbose level by setting the <var>-v 3</var> flag.
|
|
|
|
<p>As yet we have no test database set up, so the in-memory database is entirely empty.
|
|
|
|
<hr />
|
|
Go on to: <a href="trogarch.html">Troggle architecture</a><br />
|
|
Return to: <a href="trogintro.html">Troggle intro</a><br />
|
|
Troggle index:
|
|
<a href="trogindex.html">Index of all troggle documents</a><br /><hr />
|
|
</body>
|
|
</html>
|