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

Delta Between Two Patch Sets: sitescripts/reports/tests/test_resolveReport.py

Issue 29584613: #4431 - Introduce sitescripts.reports.web.resolveReport handler (Closed)
Left Patch Set: Created Oct. 20, 2017, 1:46 p.m.
Right Patch Set: Address comments on PS1 Created Oct. 24, 2017, 3:35 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 | « sitescripts/reports/README.md ('k') | sitescripts/reports/web/resolveReport.py » ('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-present eyeo GmbH 2 # Copyright (C) 2017-present eyeo GmbH
mathias 2017/10/24 14:53:44 Shouldn't this read 2017-present?
Vasily Kuznetsov 2017/10/24 15:36:57 Yeah, I guess, this would make more sense. Done
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 base64 16 import base64
17 import ConfigParser 17 import ConfigParser
18 18
19 import pytest 19 import pytest
20 20
21 from sitescripts.reports.web.resolveReport import ( 21 from sitescripts.reports.web.resolveReport import (
22 resolve_report, 22 resolve_report,
23 CONF_SECTION, 23 CONF_SECTION,
24 CONF_KEY_KEY, 24 CONF_KEY_KEY,
25 CONF_URL_KEY, 25 CONF_URL_KEY,
26 ) 26 )
27 27
28 ENCRYPTION_KEY = '12345678901234567890123456789012' 28 ENCRYPTION_KEY = '12345678901234567890123456789012'
29 URL_TEMPLATE = 'https://report.server.com/{report_id}' 29 URL_TEMPLATE = 'https://example.com/{report_id}'
mathias 2017/10/24 14:53:44 I recommend always using example.com in defaults,
Vasily Kuznetsov 2017/10/24 15:36:57 Done.
30 30
31 PLAINTEXT_GUID = '12345678-1234-1234-1234-123456789abc' 31 PLAINTEXT_GUID = '12345678-1234-1234-1234-123456789abc'
32 ENCRYPTED_GUID = ('MTIzNDU2Nzg5YWJj,9RuQq5zPNVw2fnjk7zT/jfS+YkDRjWFrly' 32 ENCRYPTED_GUID = ('MTIzNDU2Nzg5YWJj,9RuQq5zPNVw2fnjk7zT/jfS+YkDRjWFrly'
33 'YIRRrhdeiuy86yaBq0eqA7iTLwIfjzs1yefw==') 33 'YIRRrhdeiuy86yaBq0eqA7iTLwIfjzs1yefw==')
34 34
35 BAD_GUIDS = [ 35 BAD_GUIDS = [
36 '', # Nothing. 36 '', # Nothing.
37 'foobar', # No comma. 37 'foobar', # No comma.
38 # Wrong base64 encoding. 38 # Wrong base64 encoding.
39 'TIzNDU2Nzg5YWJj,9RuQq5zPNVw2fnjk7zT/jfS+YkDRjWFrly' 39 'TIzNDU2Nzg5YWJj,9RuQq5zPNVw2fnjk7zT/jfS+YkDRjWFrly'
(...skipping 27 matching lines...) Expand all
67 ) 67 )
68 68
69 69
70 @pytest.mark.parametrize('guid', BAD_GUIDS) 70 @pytest.mark.parametrize('guid', BAD_GUIDS)
71 def test_bad_wrong_guid(reports_config, mocker, guid): 71 def test_bad_wrong_guid(reports_config, mocker, guid):
72 start_response_mock = mocker.Mock() 72 start_response_mock = mocker.Mock()
73 result = resolve_report({'QUERY_STRING': guid}, 73 result = resolve_report({'QUERY_STRING': guid},
74 start_response_mock) 74 start_response_mock)
75 assert result == ['Not Found'] 75 assert result == ['Not Found']
76 start_response_mock.assert_called_once_with('404 Not Found', []) 76 start_response_mock.assert_called_once_with('404 Not Found', [])
LEFTRIGHT

Powered by Google App Engine
This is Rietveld