forked from beba/foerderbarometer
added more tests for extern view
This commit is contained in:
parent
0afabe9325
commit
eaddabbcdd
|
|
@ -11,21 +11,56 @@ class ViewTestCase(TestCase):
|
||||||
def test_extern(self):
|
def test_extern(self):
|
||||||
request(self, 'extern')
|
request(self, 'extern')
|
||||||
|
|
||||||
def test_extern_travel(self):
|
@staticmethod
|
||||||
data = {
|
def get_step_data(step, data):
|
||||||
'extern_view-current_step': 0,
|
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-realname': 'Test',
|
||||||
'0-email': 'test@example.com',
|
'0-email': 'test@example.com',
|
||||||
'0-choice': 'TRAV',
|
'0-choice': choice,
|
||||||
'0-check': True,
|
'0-check': True,
|
||||||
}
|
})
|
||||||
|
|
||||||
response = request(self, 'extern', data=data)
|
def helper_extern(self, choice, text, data):
|
||||||
|
first_step_data = self.get_first_step_data(choice)
|
||||||
|
|
||||||
self.assertContains(response, 'Transportmittel')
|
response = request(self, 'extern', data=first_step_data)
|
||||||
|
|
||||||
data = {
|
self.assertContains(response, text)
|
||||||
'extern_view-current_step': 1,
|
|
||||||
|
second_step_data = self.get_step_data(1, data)
|
||||||
|
|
||||||
|
response = request(self, 'extern', data=second_step_data)
|
||||||
|
|
||||||
|
self.assertContains(response, 'Deine Anfrage wurde gesendet.')
|
||||||
|
|
||||||
|
def test_extern_first_steps(self):
|
||||||
|
types = [
|
||||||
|
('BIB', 'Bibliotheksausweis'),
|
||||||
|
('ELIT', 'Online-Ressource'),
|
||||||
|
('MAIL', 'Mailadresse beantragen'),
|
||||||
|
('IFG', 'gewonnenen Informationen'),
|
||||||
|
('LIT', 'Literatur verwenden'),
|
||||||
|
('LIST', 'Mailingliste beantragen'),
|
||||||
|
('TRAV', 'Transportmittel'),
|
||||||
|
('SOFT', 'Lizenz'),
|
||||||
|
('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)
|
||||||
|
|
||||||
|
self.assertContains(response, text)
|
||||||
|
|
||||||
|
def test_extern_travel(self):
|
||||||
|
self.helper_extern('TRAV', 'Transportmittel', {
|
||||||
'project_name': 'Test',
|
'project_name': 'Test',
|
||||||
'transport': 'BAHN',
|
'transport': 'BAHN',
|
||||||
'travelcost': 10,
|
'travelcost': 10,
|
||||||
|
|
@ -33,8 +68,24 @@ class ViewTestCase(TestCase):
|
||||||
'checkout': '2025-01-02',
|
'checkout': '2025-01-02',
|
||||||
'hotel': 'TRUE',
|
'hotel': 'TRUE',
|
||||||
'notes': '',
|
'notes': '',
|
||||||
}
|
})
|
||||||
|
|
||||||
response = request(self, 'extern', data=data)
|
def test_extern_lit(self):
|
||||||
|
self.helper_extern('LIT', 'Literatur verwenden', {
|
||||||
|
'cost': 20,
|
||||||
|
'info': 'Test',
|
||||||
|
'source': 'Test',
|
||||||
|
'notes': '',
|
||||||
|
'selfbuy': 'TRUE',
|
||||||
|
'selfbuy_data': 'NONE',
|
||||||
|
'selfbuy_give_data': True,
|
||||||
|
'check': True,
|
||||||
|
})
|
||||||
|
|
||||||
self.assertContains(response, 'Deine Anfrage wurde gesendet.')
|
def test_extern_bib(self):
|
||||||
|
self.helper_extern('BIB', 'Bibliotheksausweis', {
|
||||||
|
'cost': 20,
|
||||||
|
'library': 'Test',
|
||||||
|
'duration': 'Test',
|
||||||
|
'notes': '',
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ class ExternView(CookieWizardView):
|
||||||
form.fields['domain'].help_text = format_html("Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>möchtest du eine Mailingliste beantragen?")
|
form.fields['domain'].help_text = format_html("Mit welcher Domain, bzw. für welches Wikimedia-Projekt,<br>möchtest du eine Mailingliste beantragen?")
|
||||||
elif choice == 'TRAV':
|
elif choice == 'TRAV':
|
||||||
form = TravelForm(data)
|
form = TravelForm(data)
|
||||||
else:
|
else: # pragma: no cover
|
||||||
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in ExternView')
|
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice} in ExternView')
|
||||||
self.choice = choice
|
self.choice = choice
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue