summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-30 23:22:33 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-30 23:22:33 +0100
commit03160f3863a5ca16f07d82b7b11d6b1b83f50f8f (patch)
treeaf969069597a10945c9542b7575c9e8719ccbea2
parent7368942488de79ae96d3c8cc3d8f80732636f7b5 (diff)
downloadtroggle-03160f3863a5ca16f07d82b7b11d6b1b83f50f8f.tar.gz
troggle-03160f3863a5ca16f07d82b7b11d6b1b83f50f8f.tar.bz2
troggle-03160f3863a5ca16f07d82b7b11d6b1b83f50f8f.zip
Fix upload file test
-rw-r--r--core/TESTS/tests_logins.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py
index 1637a2c..0cbdad9 100644
--- a/core/TESTS/tests_logins.py
+++ b/core/TESTS/tests_logins.py
@@ -11,7 +11,6 @@ from http import HTTPStatus
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
-
class DataTests(TestCase ):
'''These check that the NULL and NON-UNIQUE constraints are working in the database '''
@@ -64,7 +63,7 @@ class FixturePageTests(TestCase):
self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but still managed to get the Admin page' )
class PostTests(TestCase):
- '''
+ '''Tests scanupload form
'''
fixtures = ['auth_users']
@@ -88,14 +87,18 @@ class PostTests(TestCase):
logged_in = c.login(username=u.username, password='secretword')
with open('README.txt','r') as testf:
- response = self.client.post('/scanupload/2021:02', data={'title': '2021#00', 'name': 'README.txt', 'scanfiles': testf })
+ response = self.client.post('/scanupload/2021:00', data={'title': '2021#00', 'name': 'README.txt', 'scanfiles': testf })
content = response.content.decode()
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, HTTPStatus.OK)
- # with open('test_up.html', 'w') as f:
- # f.write(content)
- t = re.search(r'README.txt', content)
- self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but failed to upload file' )
+ with open('test_up.html', 'w') as f:
+ f.write(content)
+ t = re.search('<em>\'README', content)
+ self.assertIsNotNone(t, 'Logged in but failed to see "<em>\'README"' )
+ t = re.search(' saved as', content)
+ self.assertIsNotNone(t, 'Logged in but failed to see "File(s) saved as"' )
+ t = re.search('/expofiles/surveyscans/2021/2021%2300/README', content)
+ self.assertIsNotNone(t, 'Logged in but failed to see "/expofiles/..."' )