mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 08:27:10 +00:00
Fix upload file test
This commit is contained in:
@@ -11,7 +11,6 @@ from http import HTTPStatus
|
|||||||
|
|
||||||
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
|
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DataTests(TestCase ):
|
class DataTests(TestCase ):
|
||||||
'''These check that the NULL and NON-UNIQUE constraints are working in the database '''
|
'''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' )
|
self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but still managed to get the Admin page' )
|
||||||
|
|
||||||
class PostTests(TestCase):
|
class PostTests(TestCase):
|
||||||
'''
|
'''Tests scanupload form
|
||||||
'''
|
'''
|
||||||
fixtures = ['auth_users']
|
fixtures = ['auth_users']
|
||||||
|
|
||||||
@@ -88,14 +87,18 @@ class PostTests(TestCase):
|
|||||||
logged_in = c.login(username=u.username, password='secretword')
|
logged_in = c.login(username=u.username, password='secretword')
|
||||||
|
|
||||||
with open('README.txt','r') as testf:
|
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()
|
content = response.content.decode()
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
# with open('test_up.html', 'w') as f:
|
with open('test_up.html', 'w') as f:
|
||||||
# f.write(content)
|
f.write(content)
|
||||||
t = re.search(r'README.txt', content)
|
t = re.search('<em>\'README', content)
|
||||||
self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but failed to upload file' )
|
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/..."' )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user