Browse Source

added first step for test_bib

master
Benni Baermann 3 years ago
parent
commit
0da3b2a4b5
1 changed files with 35 additions and 1 deletions
  1. +35
    -1
      input/tests.py

+ 35
- 1
input/tests.py View File

@ -1,15 +1,18 @@
from django.test import TestCase, Client
from django.conf import settings
from django.contrib.auth.models import User
from django.http import HttpResponse
from datetime import date
from .models import HonoraryCertificate, Project, Account, Literature
from .forms import LibraryForm
class TestWithoutLogin(TestCase):
def setUp(self):
#this supress an unwanted warning about missing root dir
#this setting supress an unwanted warning about missing root dir
settings.WHITENOISE_AUTOREFRESH = True
self.client = Client()
def test_set_granted(self):
'''test if the model function set_granted() works as intended'''
@ -30,6 +33,37 @@ class TestWithoutLogin(TestCase):
response = self.client.get('/intern', follow=True)
self.assertContains(response,'password')
def _postform(self, data, expected_form):
'''helper function to manage the Wizzard'''
response = self.client.post('/', data, follow=True)
# print(type(response))
self.assertEqual(200, self.response.status_code)
if not type(response) == HttpResponse:
if 'form' in response.context:
self.assertFalse(response.context['form'].errors)
else:
print(response.context)
raise BaseException("NO FORM FOUND")
self.assertEqual(
type(response.context['wizard']['form']),
expected_form
)
return response
def test_bib(self):
'''full run through the forms to check Bibliotheksstipendium'''
self.response = self.client.get('/')
self.assertEqual(200, self.response.status_code)
response = self._postform({
'extern_view-current_step': '0',
'0-realname': 'vladimir reiherzehe',
'0-email': 'vlre@wikimedia.de',
'0-username': 'stoffel',
'0-choice': 'BIB',
'0-check': True
}, LibraryForm)
class TestWithLogin(TestCase):

Loading…
Cancel
Save