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

Side by Side Diff: sitescripts/oauth2dl/test/test_oauth2dl.py

Issue 29934555: Noissue - Quickfix for tests failing in oauth2dl (Closed)
Patch Set: Created Nov. 2, 2018, 11:20 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 test_env = {'OAUTH2_KEY': 'env_test.json', 128 test_env = {'OAUTH2_KEY': 'env_test.json',
129 'OAUTH2_SCOPE': 'env_test_scope'} 129 'OAUTH2_SCOPE': 'env_test_scope'}
130 _, stderr, _ = run_script('www.test.com', env=test_env) 130 _, stderr, _ = run_script('www.test.com', env=test_env)
131 131
132 assert cnts.KEYFILE_NOT_FOUND_ERROR not in stderr 132 assert cnts.KEYFILE_NOT_FOUND_ERROR not in stderr
133 assert cnts.SCOPE_NOT_FOUND_ERROR not in stderr 133 assert cnts.SCOPE_NOT_FOUND_ERROR not in stderr
134 134
135 135
136 @pytest.mark.parametrize('key, expected_stderr, expected_code', [ 136 @pytest.mark.parametrize('key, expected_stderr, expected_code', [
137 ('keyfile_missing_key.json', 'Invalid key file format!', 1), 137 ('keyfile_missing_key.json', 'Invalid key file format!', 1),
138 ('keyfile_invalid_private_key.json', 'invalid_client: The OAuth ' 138 ('keyfile_invalid_private_key.json', 'invalid_grant: Not a valid email '
139 'client was not found.', 1), 139 'or user ID.', 1),
140 ('keyfile_invalid_type.json', "('Unexpected credentials type', u'invalid'," 140 ('keyfile_invalid_type.json', "('Unexpected credentials type', u'invalid',"
141 " 'Expected', 'service_account')", 1), 141 " 'Expected', 'service_account')", 1),
142 ('good_keyfile.json', 'invalid_client: The OAuth client was not found.', 142 ('good_keyfile.json', 'invalid_grant: Not a valid email or user ID.',
143 1), 143 1),
144 ]) 144 ])
145 def test_keyfile_errors(rootdir, key, expected_stderr, expected_code): 145 def test_keyfile_errors(rootdir, key, expected_stderr, expected_code):
146 """Testing how the script handles key file-related error messages. 146 """Testing how the script handles key file-related error messages.
147 147
148 Connects to the actual google API, using set of dummy key files. 148 Connects to the actual google API, using set of dummy key files.
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',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 url = 'https://www.googleapis.com/download?path={0}'.format( 187 url = 'https://www.googleapis.com/download?path={0}'.format(
188 str(rootdir.join('inexistent_file'))) 188 str(rootdir.join('inexistent_file')))
189 scope = 'www.googleapis.com' 189 scope = 'www.googleapis.com'
190 190
191 with Httplib2Interceptor(get_intercept_app, host='www.googleapis.com', 191 with Httplib2Interceptor(get_intercept_app, host='www.googleapis.com',
192 port=443): 192 port=443):
193 headers, data = download_file(url, keyfile_path, scope) 193 headers, data = download_file(url, keyfile_path, scope)
194 194
195 assert 'NOT FOUND' in data.upper() 195 assert 'NOT FOUND' in data.upper()
196 assert headers['status'] == '404' 196 assert headers['status'] == '404'
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld