diff --git a/input/tests/views.py b/input/tests/views.py index 53101d5..9bd961d 100644 --- a/input/tests/views.py +++ b/input/tests/views.py @@ -9,7 +9,7 @@ class AnonymousViewTestCase(TestCase): def test_index(self): response = request(self, 'index') - self.assertContains(response,'Sourcecode') + self.assertContains(response, 'Sourcecode') def test_extern(self): request(self, 'extern') @@ -131,3 +131,36 @@ class AuthenticatedViewTestCase(TestCase): def test_deny_error(self): 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\.)' + )