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

Side by Side Diff: chrome/common/extensions/docs/server2/integration_test.py

Issue 17816005: Doc server broken link detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Additional information for broken anchor links Created 7 years, 5 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 # Run build_server so that files needed by tests are copied to the local 6 # Run build_server so that files needed by tests are copied to the local
7 # third_party directory. 7 # third_party directory.
8 import build_server 8 import build_server
9 build_server.main() 9 build_server.main()
10 10
11 import logging
12 import optparse 11 import optparse
13 import os 12 import os
14 import sys 13 import sys
15 import time 14 import time
16 import unittest 15 import unittest
17 16
18 from local_renderer import LocalRenderer 17 from local_renderer import LocalRenderer
19 from fake_fetchers import ConfigureFakeFetchers 18 from fake_fetchers import ConfigureFakeFetchers
19 from find_broken_links import CreateProcessor, FindBrokenLinks
20 from handler import Handler 20 from handler import Handler
21 from servlet import Request 21 from servlet import Request
22 from test_util import EnableLogging, DisableLogging 22 from test_util import EnableLogging, DisableLogging
23 23
24 # Arguments set up if __main__ specifies them. 24 # Arguments set up if __main__ specifies them.
25 _EXPLICIT_TEST_FILES = None 25 _EXPLICIT_TEST_FILES = None
26 26
27 def _ToPosixPath(os_path): 27 def _ToPosixPath(os_path):
28 return os_path.replace(os.sep, '/') 28 return os_path.replace(os.sep, '/')
29 29
(...skipping 24 matching lines...) Expand all
54 54
55 print('Running cron...') 55 print('Running cron...')
56 start_time = time.time() 56 start_time = time.time()
57 try: 57 try:
58 response = Handler(Request.ForTest('/_cron/stable')).Get() 58 response = Handler(Request.ForTest('/_cron/stable')).Get()
59 self.assertEqual(200, response.status) 59 self.assertEqual(200, response.status)
60 self.assertEqual('Success', response.content.ToString()) 60 self.assertEqual('Success', response.content.ToString())
61 finally: 61 finally:
62 print('Took %s seconds' % (time.time() - start_time)) 62 print('Took %s seconds' % (time.time() - start_time))
63 63
64 print "Checking for broken links..."
65 failures = []
66 def writer(*args):
67 # Print out and keep track of links that failed.
68 for arg in args:
69 print arg,
70 print
71 failures.append(args)
72
73 def renderer(path):
74 return Handler(Request.ForTest(path)).Get()
75
76 start_time = time.time()
77 FindBrokenLinks(
78 CreateProcessor(renderer),
79 ('/extensions/index.html', '/apps/about_apps.html'), writer=writer)
80
81 print 'Finding %d broken links took %s seconds' % (
82 len(failures), time.time() - start_time)
83
64 public_files = _GetPublicFiles() 84 public_files = _GetPublicFiles()
65 85
66 print('Rendering %s public files...' % len(public_files.keys())) 86 print('Rendering %s public files...' % len(public_files.keys()))
67 start_time = time.time() 87 start_time = time.time()
68 try: 88 try:
69 for path, content in public_files.iteritems(): 89 for path, content in public_files.iteritems():
70 def check_result(response): 90 def check_result(response):
71 self.assertEqual(200, response.status, 91 self.assertEqual(200, response.status,
72 'Got %s when rendering %s' % (response.status, path)) 92 'Got %s when rendering %s' % (response.status, path))
73 # This is reaaaaally rough since usually these will be tiny templates 93 # This is reaaaaally rough since usually these will be tiny templates
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 128
109 if __name__ == '__main__': 129 if __name__ == '__main__':
110 parser = optparse.OptionParser() 130 parser = optparse.OptionParser()
111 parser.add_option('-a', '--all', action='store_true', default=False) 131 parser.add_option('-a', '--all', action='store_true', default=False)
112 (opts, args) = parser.parse_args() 132 (opts, args) = parser.parse_args()
113 if not opts.all: 133 if not opts.all:
114 _EXPLICIT_TEST_FILES = args 134 _EXPLICIT_TEST_FILES = args
115 # Kill sys.argv because we have our own flags. 135 # Kill sys.argv because we have our own flags.
116 sys.argv = [sys.argv[0]] 136 sys.argv = [sys.argv[0]]
117 unittest.main() 137 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698