Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/formmail/test/test_formmail.py

Issue 29350441: Noissue - Add tests for formmail handler (Closed)
Left Patch Set: Created Sept. 2, 2016, 2:35 p.m.
Right Patch Set: Rearrange the imports to follow PEP8 Created Sept. 2, 2016, 3:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | tox.ini » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 import pytest
Sebastian Noack 2016/09/02 15:09:08 corelib imports go first. Third party- modules fol
Vasily Kuznetsov 2016/09/02 15:44:30 Done.
17 from urllib import urlencode 16 from urllib import urlencode
18 from urllib2 import urlopen 17 from urllib2 import urlopen
18
19 import pytest
19 from wsgi_intercept import (urllib_intercept, add_wsgi_intercept, 20 from wsgi_intercept import (urllib_intercept, add_wsgi_intercept,
20 remove_wsgi_intercept) 21 remove_wsgi_intercept)
21 22
22 from sitescripts.formmail.web.formmail import handleRequest 23 from sitescripts.formmail.web.formmail import handleRequest
23 24
24 25
25 # We make this a fixture instead of a constant so we can modify it in each 26 # We make this a fixture instead of a constant so we can modify it in each
26 # test as needed without affecting other tests. 27 # test as needed without affecting other tests.
27 @pytest.fixture 28 @pytest.fixture
28 def form_data(): 29 def form_data():
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 85
85 def test_success(response_for, form_data, mocker): 86 def test_success(response_for, form_data, mocker):
86 sm_mock = mocker.patch('sitescripts.formmail.web.formmail.sendMail') 87 sm_mock = mocker.patch('sitescripts.formmail.web.formmail.sendMail')
87 assert response_for(form_data) == 'Message sent' 88 assert response_for(form_data) == 'Message sent'
88 assert sm_mock.call_count == 1 89 assert sm_mock.call_count == 1
89 params = sm_mock.call_args[0][1] 90 params = sm_mock.call_args[0][1]
90 assert set(params.keys()) == set(form_data.keys()) | {'time'} 91 assert set(params.keys()) == set(form_data.keys()) | {'time'}
91 for key, value in form_data.items(): 92 for key, value in form_data.items():
92 assert params[key] == value 93 assert params[key] == value
LEFTRIGHT
« no previous file | tox.ini » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld