Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: app_test.py

Issue 142243002: Fix presubmit.py tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Remove spurious spaces. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/test_console_handler/console-expected.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import ast 6 import ast
7 import datetime 7 import datetime
8 import hashlib 8 import hashlib
9 import hmac 9 import hmac
10 import json 10 import json
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js', 208 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js',
209 content='document.write(\'sheriff8\')') 209 content='document.write(\'sheriff8\')')
210 input_console = self._load_content(test_dir, 'console-input.html') 210 input_console = self._load_content(test_dir, 'console-input.html')
211 expected_console = self._load_content(test_dir, 'console-expected.html') 211 expected_console = self._load_content(test_dir, 'console-expected.html')
212 page_data = {'content': input_console} 212 page_data = {'content': input_console}
213 actual_console = app.console_handler( 213 actual_console = app.console_handler(
214 unquoted_localpath='chromium/console', 214 unquoted_localpath='chromium/console',
215 remoteurl='http://build.chromium.org/p/chromium/console', 215 remoteurl='http://build.chromium.org/p/chromium/console',
216 page_data=page_data) 216 page_data=page_data)
217 # Uncomment if deeper inspection is needed of the returned console. 217 # Uncomment if deeper inspection is needed of the returned console.
218 # This is also useful if changing the site layout and you need to
219 # 'retrain' the test expectations.
cmp 2014/01/18 01:46:07 Thanks for commenting this. It was actually the m
218 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh: 220 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh:
219 # fh.write(actual_console['content']) 221 # fh.write(actual_console['content'])
220 self.assertEquals(expected_console, actual_console['content'], 222 self.assertEquals(expected_console, actual_console['content'],
221 'Unexpected console output found') 223 'Unexpected console output found')
222 224
223 def test_console_handler_utf8(self): 225 def test_console_handler_utf8(self):
224 test_dir = os.path.join(TEST_DIR, 'test_console_handler_utf8') 226 test_dir = os.path.join(TEST_DIR, 'test_console_handler_utf8')
225 self.save_page(localpath='chromium/sheriff.js', 227 self.save_page(localpath='chromium/sheriff.js',
226 content='document.write(\'sheriff1\')') 228 content='document.write(\'sheriff1\')')
227 self.save_page(localpath='chromium/sheriff_webkit.js', 229 self.save_page(localpath='chromium/sheriff_webkit.js',
228 content='document.write(\'sheriff2\')') 230 content='document.write(\'sheriff2\')')
229 self.save_page(localpath='chromium/sheriff_memory.js', 231 self.save_page(localpath='chromium/sheriff_memory.js',
230 content='document.write(\'sheriff3\')') 232 content='document.write(\'sheriff3\')')
231 self.save_page(localpath='chromium/sheriff_nacl.js', 233 self.save_page(localpath='chromium/sheriff_nacl.js',
232 content='document.write(\'sheriff4\')') 234 content='document.write(\'sheriff4\')')
233 self.save_page(localpath='chromium/sheriff_perf.js', 235 self.save_page(localpath='chromium/sheriff_perf.js',
234 content='document.write(\'sheriff5\')') 236 content='document.write(\'sheriff5\')')
235 self.save_page(localpath='chromium/sheriff_cros_mtv.js', 237 self.save_page(localpath='chromium/sheriff_cros_mtv.js',
236 content='document.write(\'sheriff6, sheriff7\')') 238 content='document.write(\'sheriff6, sheriff7\')')
237 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js', 239 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js',
238 content='document.write(\'sheriff8\')') 240 content='document.write(\'sheriff8\')')
239 input_console = self._load_content(test_dir, 'console-input.html') 241 input_console = self._load_content(test_dir, 'console-input.html')
240 expected_console = self._load_content(test_dir, 'console-expected.html') 242 expected_console = self._load_content(test_dir, 'console-expected.html')
241 page_data = {'content': input_console} 243 page_data = {'content': input_console}
242 actual_console = app.console_handler( 244 actual_console = app.console_handler(
243 unquoted_localpath='chromium/console', 245 unquoted_localpath='chromium/console',
244 remoteurl='http://build.chromium.org/p/chromium/console', 246 remoteurl='http://build.chromium.org/p/chromium/console',
245 page_data=page_data) 247 page_data=page_data)
246 # Uncomment if deeper inspection is needed of the returned console. 248 # Uncomment if deeper inspection is needed of the returned console.
249 # This is also useful if changing the site layout and you need to
250 # 'retrain' the test expectations.
247 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh: 251 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh:
248 # fh.write(actual_console['content']) 252 # fh.write(actual_console['content'])
249 self.assertEquals(expected_console, actual_console['content'], 253 self.assertEquals(expected_console, actual_console['content'],
250 'Unexpected console output found') 254 'Unexpected console output found')
251 255
252 def test_parse_master(self): 256 def test_parse_master(self):
253 test_dir = os.path.join(TEST_DIR, 'test_parse_master') 257 test_dir = os.path.join(TEST_DIR, 'test_parse_master')
254 expected_rev = self._load_content(test_dir, 'expected-rev.html').strip() 258 expected_rev = self._load_content(test_dir, 'expected-rev.html').strip()
255 expected_name = self._load_content(test_dir, 'expected-name.html').strip() 259 expected_name = self._load_content(test_dir, 'expected-name.html').strip()
256 expected_status = self._load_content(test_dir, 260 expected_status = self._load_content(test_dir,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return fr 446 return fr
443 447
444 expected_content = self._load_content(test_dir, 'expected.html') 448 expected_content = self._load_content(test_dir, 'expected.html')
445 app.fetch_page( 449 app.fetch_page(
446 localpath='chromium/console', 450 localpath='chromium/console',
447 remoteurl='http://build.chromium.org/p/chromium/console', 451 remoteurl='http://build.chromium.org/p/chromium/console',
448 maxage=0, 452 maxage=0,
449 fetch_url=fetch_url) 453 fetch_url=fetch_url)
450 page = app.get_and_cache_pagedata('chromium/console') 454 page = app.get_and_cache_pagedata('chromium/console')
451 # Uncomment if deeper inspection is needed of the returned console. 455 # Uncomment if deeper inspection is needed of the returned console.
456 # This is also useful if changing the site layout and you need to
457 # 'retrain' the test expectations.
452 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh: 458 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh:
453 # fh.write(page['content']) 459 # fh.write(page['content'])
454 self.assertEquals(expected_content, page['content']) 460 self.assertEquals(expected_content, page['content'])
455 461
456 def test_fetch_console(self): 462 def test_fetch_console(self):
457 test_dir = os.path.join(TEST_DIR, 'test_fetch_console') 463 test_dir = os.path.join(TEST_DIR, 'test_fetch_console')
458 464
459 def fetch_url(url): 465 def fetch_url(url):
460 fr = FetchTestCase.FakeResponse() 466 fr = FetchTestCase.FakeResponse()
461 if url == 'http://build.chromium.org/p/chromium/console': 467 if url == 'http://build.chromium.org/p/chromium/console':
462 fr.content = self._load_content(test_dir, 'input.html') 468 fr.content = self._load_content(test_dir, 'input.html')
463 return fr 469 return fr
464 470
465 expected_content = self._load_content(test_dir, 'expected.html') 471 expected_content = self._load_content(test_dir, 'expected.html')
466 app.fetch_page( 472 app.fetch_page(
467 localpath='chromium/console', 473 localpath='chromium/console',
468 remoteurl='http://build.chromium.org/p/chromium/console', 474 remoteurl='http://build.chromium.org/p/chromium/console',
469 maxage=0, 475 maxage=0,
470 postfetch=app.console_handler, 476 postfetch=app.console_handler,
471 fetch_url=fetch_url) 477 fetch_url=fetch_url)
472 page = app.get_and_cache_pagedata('chromium/console') 478 page = app.get_and_cache_pagedata('chromium/console')
473 # Uncomment if deeper inspection is needed of the returned console. 479 # Uncomment if deeper inspection is needed of the returned console.
480 # This is also useful if changing the site layout and you need to
481 # 'retrain' the test expectations.
474 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh: 482 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh:
475 # fh.write(page['content']) 483 # fh.write(page['content'])
476 self.assertEquals('interface', page['body_class']) 484 self.assertEquals('interface', page['body_class'])
477 self.assertEquals(expected_content, page['content']) 485 self.assertEquals(expected_content, page['content'])
478 self.assertEquals( 486 self.assertEquals(
479 'http://build.chromium.org/p/chromium/console/../', 487 'http://build.chromium.org/p/chromium/console/../',
480 page['offsite_base']) 488 page['offsite_base'])
481 self.assertEquals('BuildBot: Chromium', page['title']) 489 self.assertEquals('BuildBot: Chromium', page['title'])
482 490
483 491
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 ] 551 ]
544 552
545 for test_json in tests: 553 for test_json in tests:
546 # pylint: disable=W0212 554 # pylint: disable=W0212
547 self.assertFalse(Email._validate_message(test_json, url, secret)) 555 self.assertFalse(Email._validate_message(test_json, url, secret))
548 556
549 test_json = self._hash_message(time.time(), message, url, secret) 557 test_json = self._hash_message(time.time(), message, url, secret)
550 test_json['message'] = test_json['message'] + 'hey' 558 test_json['message'] = test_json['message'] + 'hey'
551 # pylint: disable=W0212 559 # pylint: disable=W0212
552 self.assertFalse(Email._validate_message(test_json, url, secret)) 560 self.assertFalse(Email._validate_message(test_json, url, secret))
OLDNEW
« no previous file with comments | « no previous file | tests/test_console_handler/console-expected.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698