add negative test for Literature form submission without terms_accepted

This commit is contained in:
Roman 2025-09-01 01:45:50 +02:00
parent 0d033e7e25
commit ed2db04309
1 changed files with 34 additions and 1 deletions

View File

@ -9,7 +9,7 @@ class AnonymousViewTestCase(TestCase):
def test_index(self): def test_index(self):
response = request(self, 'index') response = request(self, 'index')
self.assertContains(response,'<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a>') self.assertContains(response, '<a href="https://srcsrv.wikimedia.de/beba/foerderbarometer">Sourcecode</a>')
def test_extern(self): def test_extern(self):
request(self, 'extern') request(self, 'extern')
@ -131,3 +131,36 @@ class AuthenticatedViewTestCase(TestCase):
def test_deny_error(self): def test_deny_error(self):
self.helper_auth_deny_error('deny') self.helper_auth_deny_error('deny')
class TermsConsentViewTests(AnonymousViewTestCase):
def test_extern_lit(self):
"""
Negative case: Literature form without terms_accepted must not succeed
and should display a required field error.
"""
# Step 1
resp = request(self, 'extern', data=self.get_first_step_data('LIT'))
self.assertContains(resp, 'Literatur verwenden')
# Step 2: submit without terms_accepted
payload = self.get_step_data(1, {
'cost': 20,
'info': 'Test',
'source': 'Test',
'notes': '',
'selfbuy': 'TRUE',
'selfbuy_data': 'NONE',
'selfbuy_give_data': 'on', # checkbox checked
# terms_accepted intentionally omitted
})
resp = request(self, 'extern', data=payload)
# Expect to remain on step 2 with required field error
self.assertEqual(resp.status_code, 200)
self.assertNotContains(resp, 'Deine Anfrage wurde gesendet.')
self.assertRegex(
resp.content.decode(),
r'(Dieses Feld ist erforderlich|This field is required\.)'
)