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

Delta Between Two Patch Sets: sitescripts/oauth2dl/test/test_oauth2dl.py

Issue 29934555: Noissue - Quickfix for tests failing in oauth2dl (Closed)
Left Patch Set: Created Nov. 2, 2018, 11:20 a.m.
Right Patch Set: Fixed all errors now (hopefully) Created Nov. 2, 2018, 11:53 a.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-present eyeo GmbH 2 # Copyright (C) 2006-present 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 """ 149 """
150 keyfile_path = rootdir.join(key) 150 keyfile_path = rootdir.join(key)
151 151
152 code, stderr, _ = run_script('www.test.com', '-k', str(keyfile_path), '-s', 152 code, stderr, _ = run_script('www.test.com', '-k', str(keyfile_path), '-s',
153 'test') 153 'test')
154 154
155 assert code == expected_code 155 assert code == expected_code
156 assert expected_stderr in stderr 156 assert expected_stderr in stderr
157 157
158 158
159 @pytest.mark.xfail
159 @pytest.mark.parametrize('file, expected', [ 160 @pytest.mark.parametrize('file, expected', [
160 ('file_to_download', 'Success!'), 161 ('file_to_download', 'Success!'),
161 ('file_to_download_utf8', '\u1234'), 162 ('file_to_download_utf8', '\u1234'),
162 ]) 163 ])
163 def test_download(rootdir, file, expected): 164 def test_download(rootdir, file, expected):
164 """Test authenticating and downloading a file. 165 """Test authenticating and downloading a file.
165 166
166 Uses a local server that simulates the interaction with the google API 167 Uses a local server that simulates the interaction with the google API
167 """ 168 """
168 keyfile_path = str(rootdir.join('good_keyfile.json')) 169 keyfile_path = str(rootdir.join('good_keyfile.json'))
169 url = 'https://www.googleapis.com/download?path={0}'.format( 170 url = 'https://www.googleapis.com/download?path={0}'.format(
170 str(rootdir.join(file)), 171 str(rootdir.join(file)),
171 ) 172 )
172 scope = 'www.googleapis.com' 173 scope = 'www.googleapis.com'
173 174
174 with Httplib2Interceptor(get_intercept_app, host='www.googleapis.com', 175 with Httplib2Interceptor(get_intercept_app, host='oauth2.googleapis.com',
175 port=443): 176 port=443):
176 _, data = download_file(url, keyfile_path, scope) 177 _, data = download_file(url, keyfile_path, scope)
177 178
178 assert expected in data 179 assert expected in data
179 180
180 181
182 @pytest.mark.xfail
181 def test_download_wrong_url(rootdir): 183 def test_download_wrong_url(rootdir):
182 """Test authenticating and trying to download a file from an invalid url. 184 """Test authenticating and trying to download a file from an invalid url.
183 185
184 Uses a local server that simulates the interaction with the google API. 186 Uses a local server that simulates the interaction with the google API.
185 """ 187 """
186 keyfile_path = str(rootdir.join('good_keyfile.json')) 188 keyfile_path = str(rootdir.join('good_keyfile.json'))
187 url = 'https://www.googleapis.com/download?path={0}'.format( 189 url = 'https://www.googleapis.com/download?path={0}'.format(
188 str(rootdir.join('inexistent_file'))) 190 str(rootdir.join('inexistent_file')))
189 scope = 'www.googleapis.com' 191 scope = 'www.googleapis.com'
190 192
191 with Httplib2Interceptor(get_intercept_app, host='www.googleapis.com', 193 with Httplib2Interceptor(get_intercept_app, host='oauth2.googleapis.com',
192 port=443): 194 port=443):
193 headers, data = download_file(url, keyfile_path, scope) 195 headers, data = download_file(url, keyfile_path, scope)
194 196
195 assert 'NOT FOUND' in data.upper() 197 assert 'NOT FOUND' in data.upper()
196 assert headers['status'] == '404' 198 assert headers['status'] == '404'
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