From 0da3b2a4b5c069f53975bbbb4a2b9f63291aee65 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 11 Oct 2021 13:04:28 +0200 Subject: [PATCH] added first step for test_bib --- input/tests.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/input/tests.py b/input/tests.py index 7f8d9bc..ebc1db0 100644 --- a/input/tests.py +++ b/input/tests.py @@ -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):