diff --git a/input/tests/__init__.py b/input/tests/__init__.py index 4152ba5..628691e 100755 --- a/input/tests/__init__.py +++ b/input/tests/__init__.py @@ -1,22 +1,13 @@ from datetime import date -from django.test import TestCase, Client -from django.conf import settings -from django.contrib.auth.models import User -from django.http import HttpResponse +from django.test import TestCase -from input.forms import LibraryForm from input.models import HonoraryCertificate, Project, Account, Literature from .views import ViewTestCase -class TestWithoutLogin(TestCase): - - def setUp(self): - #this setting supress an unwanted warning about missing root dir - settings.WHITENOISE_AUTOREFRESH = True - self.client = Client() +class ModelTestCase(TestCase): def test_set_granted(self): '''test if the model function set_granted() works as intended''' @@ -26,71 +17,6 @@ class TestWithoutLogin(TestCase): obj2 = HonoraryCertificate.objects.get(pk=obj.pk) self.assertEqual(obj2.granted,True) - def test_source_link(self): - '''test if link to source code is included in main page''' - response = self.client.get('', follow=True) - #print (response.content) - self.assertContains(response,'Sourcecode') - - def _postform(self, data, expected_form): - '''helper function to manage the Wizzard''' - response = self.client.post('/', data, follow=False) - self.assertEqual(200, self.response.status_code) - if not type(response) == HttpResponse: - if 'form' in response.context: - print('CONTENT') - print(response.content) - print('ITEMS') - print(response.items()) - print('DATA') - print(data) - self.assertFalse(response.context['form'].errors) - else: - if expected_form: - print(response.context) - raise BaseException("NO FORM FOUND") - else: - self.assertContains(response,"Deine Anfrage wurde gesendet.") - self.assertEqual( - type(response.context['wizard']['form']), - expected_form - ) - return response - - def _notest_bib(self): # renamed because not working - '''full run through the forms to check Bibliotheksstipendium''' - self.response = self.client.get('/') - self.assertEqual(200, self.response.status_code) - - print("\n\nEINS EINS\n\n") - - 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) - - print("\n\nZWEI ZWEI\n\n") - - response = self._postform({ - 'extern_view-current_step': '1', - '1-cost': 'teuroooo!', - '1-duration': 'looooong', - '1-library': 'of congress', - }, None) - - - -class TestWithLogin(TestCase): - - def setUp(self): - User.objects.create_superuser('testuser', 'nomail@nomail.com', 'testpasswd') - self.client = Client() - self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe') - def test_project_of_year(self): ''' test if the finance id is resettet ad start of year''' acc = Account.objects.create() diff --git a/input/tests/views.py b/input/tests/views.py index e69d374..5c0950d 100644 --- a/input/tests/views.py +++ b/input/tests/views.py @@ -6,7 +6,9 @@ from input.utils.testing import request class ViewTestCase(TestCase): def test_index(self): - request(self, 'index') + response = request(self, 'index') + + self.assertContains(response,'Sourcecode') def test_extern(self): request(self, 'extern')