forked from beba/foerderbarometer
fixed tests
This commit is contained in:
parent
a7d3df7b39
commit
ce4aeb0721
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import date, timedelta
|
||||
|
||||
from django.core.management import CommandError
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.template.loader import get_template
|
||||
from django.core.mail import BadHeaderError
|
||||
|
|
@ -50,8 +51,8 @@ class Command(BaseCommand):
|
|||
# [email],
|
||||
# bcc=[SURVEY_EMAIL])
|
||||
#survey_mail.send(fail_silently=False)
|
||||
except BadHeaderError:
|
||||
return HttpResponse('Invalid header found.') # FIXME HttpResponse???
|
||||
except BadHeaderError as error:
|
||||
raise CommandError(f'Invalid header found: {error}')
|
||||
|
||||
print(f'send surveylinkemail to {email}...')
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
<br>Für alle Fragen wende dich gern an das <a
|
||||
href="https://de.wikipedia.org/wiki/Wikipedia:Förderung/Wikimedia_Deutschland">Team Communitys und
|
||||
Engagement</a>.
|
||||
<br>Für interessierte Hacker gibts auch den <a
|
||||
href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a> zum Formular und was damit passiert.
|
||||
<br>Für interessierte Hacker gibts auch den
|
||||
<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a> zum Formular und was damit passiert.
|
||||
<p>
|
||||
<a href="https://www.wikimedia.de/impressum/">Impressum</a>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from django.shortcuts import resolve_url
|
||||
from django.test import TestCase
|
||||
|
||||
from input.models import Library
|
||||
from input.utils.testing import create_superuser, login, request
|
||||
from input.views import TYPES
|
||||
|
||||
|
||||
class AnonymousViewTestCase(TestCase):
|
||||
|
|
@ -14,33 +16,36 @@ class AnonymousViewTestCase(TestCase):
|
|||
def test_extern(self):
|
||||
request(self, 'extern')
|
||||
|
||||
@staticmethod
|
||||
def get_step_data(step, data):
|
||||
return {'extern_view-current_step': step, **data}
|
||||
|
||||
@classmethod
|
||||
def get_first_step_data(cls, choice):
|
||||
return cls.get_step_data(0, {
|
||||
'0-realname': 'Test',
|
||||
'0-email': 'test@example.com',
|
||||
'0-choice': choice,
|
||||
'0-check': True,
|
||||
})
|
||||
def get_step_data(cls, choice, **data):
|
||||
return {
|
||||
'realname': 'Test',
|
||||
'email': 'test@example.com',
|
||||
'choice': choice,
|
||||
'check': True,
|
||||
**data,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def helper_url(code):
|
||||
info = next(info for info in TYPES if info.code == code)
|
||||
|
||||
return resolve_url('extern', type=info.path)
|
||||
|
||||
def helper_extern(self, choice, text, data):
|
||||
first_step_data = self.get_first_step_data(choice)
|
||||
url = self.helper_url(choice)
|
||||
|
||||
response = request(self, 'extern', data=first_step_data)
|
||||
response = request(self, url)
|
||||
|
||||
self.assertContains(response, text)
|
||||
|
||||
second_step_data = self.get_step_data(1, data)
|
||||
data = self.get_step_data(choice, **data)
|
||||
|
||||
response = request(self, 'extern', data=second_step_data)
|
||||
response = request(self, url, data=data)
|
||||
|
||||
self.assertContains(response, 'Deine Anfrage wurde gesendet.')
|
||||
|
||||
def test_extern_first_steps(self):
|
||||
def test_extern_steps(self):
|
||||
types = [
|
||||
('BIB', 'Bibliotheksausweis'),
|
||||
('ELIT', 'Online-Ressource'),
|
||||
|
|
@ -53,12 +58,10 @@ class AnonymousViewTestCase(TestCase):
|
|||
('VIS', 'DIN 5008'),
|
||||
]
|
||||
|
||||
for choice, text in types:
|
||||
with self.subTest(type=choice):
|
||||
self.client.session.clear()
|
||||
|
||||
data = self.get_first_step_data(choice)
|
||||
response = request(self, 'extern', data=data)
|
||||
for code, text in types:
|
||||
with self.subTest(type=code):
|
||||
url = self.helper_url(code)
|
||||
response = request(self, url)
|
||||
|
||||
self.assertContains(response, text)
|
||||
|
||||
|
|
@ -93,6 +96,10 @@ class AnonymousViewTestCase(TestCase):
|
|||
'notes': '',
|
||||
})
|
||||
|
||||
def test_extern_invalid_code(self):
|
||||
request(self, 'extern', args=['invalid'], status_code=404)
|
||||
|
||||
|
||||
|
||||
class AuthenticatedViewTestCase(TestCase):
|
||||
|
||||
|
|
@ -159,4 +166,4 @@ class TermsConsentViewTests(AnonymousViewTestCase):
|
|||
|
||||
# Expect to remain on step 2 with required field error
|
||||
self.assertNotContains(resp, 'Deine Anfrage wurde gesendet.')
|
||||
self.assertContains(resp, 'Dieses Feld ist zwingend erforderlich.')
|
||||
self.assertContains(resp, 'Dieses Feld ist zwingend erforderlich.')
|
||||
|
|
|
|||
|
|
@ -73,10 +73,6 @@ class ApplicationType(NamedTuple):
|
|||
def label(self):
|
||||
return TYPE_CHOICES[self.code]
|
||||
|
||||
@property
|
||||
def model(self):
|
||||
return MODELS[self.code]
|
||||
|
||||
@property
|
||||
def help_texts(self):
|
||||
return HELP_TEXTS.get(self.code)
|
||||
|
|
|
|||
Loading…
Reference in New Issue