LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 Eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') | 81 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') |
82 form_data['non_mandatory'] = '' | 82 form_data['non_mandatory'] = '' |
83 assert response_for(form_data) == (200, '') | 83 assert response_for(form_data) == (200, '') |
84 | 84 |
85 | 85 |
86 def test_invalid_email_cstm_msg(response_for, form_data, mocker, form_config): | 86 def test_invalid_email_cstm_msg(response_for, form_data, mocker, form_config): |
87 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') | 87 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') |
88 form_data['email'] = 'bademail' | 88 form_data['email'] = 'bademail' |
89 with pytest.raises(HTTPError) as error: | 89 with pytest.raises(HTTPError) as error: |
90 response_for(form_data) | 90 response_for(form_data) |
91 thang = error.value.read() | 91 assert error.value.read() == 'You failed the email validation' |
92 assert thang == 'You failed the email validation' | |
93 | 92 |
94 | 93 |
95 def test_valid_nan_mandatory_email(response_for, form_data, mocker): | 94 def test_valid_nan_mandatory_email(response_for, form_data, mocker): |
96 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') | 95 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') |
97 form_data['non_mandatory_email'] = '' | 96 form_data['non_mandatory_email'] = 'asfaf' |
98 assert response_for(form_data) == (200, '') | 97 with pytest.raises(HTTPError) as error: |
| 98 response_for(form_data) |
| 99 assert error.value.read() == 'Invalid email' |
99 | 100 |
100 del form_data['non_mandatory_email'] | 101 del form_data['non_mandatory_email'] |
101 assert response_for(form_data) == (200, '') | 102 assert response_for(form_data) == (200, '') |
102 | 103 |
103 | 104 |
104 def test_mandatory_fail_dflt_msg(response_for, form_data, mocker): | 105 def test_mandatory_fail_dflt_msg(response_for, form_data, mocker): |
105 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') | 106 mocker.patch('sitescripts.formmail.web.formmail2.sendMail') |
106 del form_data['mandatory'] | 107 del form_data['mandatory'] |
107 with pytest.raises(HTTPError) as error: | 108 with pytest.raises(HTTPError) as error: |
108 response_for(form_data) | 109 response_for(form_data) |
109 assert error.value.read() == 'No mandatory entered' | 110 assert error.value.read() == 'No mandatory entered' |
LEFT | RIGHT |