diff options
Diffstat (limited to 'core/TESTS/tests_logins.py')
-rw-r--r-- | core/TESTS/tests_logins.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py index 45bd33e..66e69c6 100644 --- a/core/TESTS/tests_logins.py +++ b/core/TESTS/tests_logins.py @@ -7,6 +7,8 @@ Modified for Expo April 2021. import unittest import re +from http import HTTPStatus + from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client @@ -61,6 +63,41 @@ class FixturePageTests(TestCase): t = re.search(r'Troggle administration', content) self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but still managed to get the Admin page' ) +class PostTests(TestCase): + ''' + ''' + fixtures = ['auth_users'] + + @classmethod + def setUpTestData(cls): + pass + + def setUp(self): + from django.contrib.auth.models import User + self.user = User.objects.get(username='expotest') + self.client = Client() + + def test_scan_upload(self): + '''Test file upload. Need to login first. + ''' + c = self.client + from django.contrib.auth.models import User + u = User.objects.get(username='expotest') + + self.assertTrue(u.is_active, 'User \'' + u.username + '\' is INACTIVE') + 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 }) + 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' ) + + class ComplexLoginTests(TestCase): '''These test the login and capabilities of logged-in users, they do not use fixtures''' |