forked from expo/troggle
Fix upload file test
This commit is contained in:
parent
7368942488
commit
03160f3863
@ -12,7 +12,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 '''
|
||||
@classmethod
|
||||
@ -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/..."' )
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user