forked from beba/foerderbarometer
added first step for test_bib
This commit is contained in:
parent
fd46dd2f5a
commit
0da3b2a4b5
|
@ -1,15 +1,18 @@
|
||||||
from django.test import TestCase, Client
|
from django.test import TestCase, Client
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.http import HttpResponse
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from .models import HonoraryCertificate, Project, Account, Literature
|
from .models import HonoraryCertificate, Project, Account, Literature
|
||||||
|
from .forms import LibraryForm
|
||||||
|
|
||||||
class TestWithoutLogin(TestCase):
|
class TestWithoutLogin(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
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
|
settings.WHITENOISE_AUTOREFRESH = True
|
||||||
|
self.client = Client()
|
||||||
|
|
||||||
def test_set_granted(self):
|
def test_set_granted(self):
|
||||||
'''test if the model function set_granted() works as intended'''
|
'''test if the model function set_granted() works as intended'''
|
||||||
|
@ -30,6 +33,37 @@ class TestWithoutLogin(TestCase):
|
||||||
response = self.client.get('/intern', follow=True)
|
response = self.client.get('/intern', follow=True)
|
||||||
self.assertContains(response,'password')
|
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):
|
class TestWithLogin(TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue