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

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

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples Created 7 years, 1 month 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from extensions_paths import PUBLIC_TEMPLATES
5 from instance_servlet import ( 6 from instance_servlet import (
6 InstanceServlet, InstanceServletRenderServletDelegate) 7 InstanceServlet, InstanceServletRenderServletDelegate)
7 from link_error_detector import LinkErrorDetector, StringifyBrokenLinks 8 from link_error_detector import LinkErrorDetector, StringifyBrokenLinks
8 from servlet import Request, Response, Servlet 9 from servlet import Request, Response, Servlet
9 import svn_constants 10
10 11
11 class BrokenLinkTester(object): 12 class BrokenLinkTester(object):
12 '''Run link error detector tests. 13 '''Run link error detector tests.
13 ''' 14 '''
14 def __init__(self, server_instance, renderer): 15 def __init__(self, server_instance, renderer):
15 self.link_error_detector = LinkErrorDetector( 16 self.link_error_detector = LinkErrorDetector(
16 server_instance.host_file_system_provider.GetTrunk(), 17 server_instance.host_file_system_provider.GetTrunk(),
17 renderer, 18 renderer,
18 svn_constants.PUBLIC_TEMPLATE_PATH, 19 PUBLIC_TEMPLATES,
19 root_pages=('extensions/index.html', 'apps/about_apps.html')) 20 root_pages=('extensions/index.html', 'apps/about_apps.html'))
20 21
21 def TestBrokenLinks(self): 22 def TestBrokenLinks(self):
22 broken_links = self.link_error_detector.GetBrokenLinks() 23 broken_links = self.link_error_detector.GetBrokenLinks()
23 return ( 24 return (
24 len(broken_links), 25 len(broken_links),
25 'Warning: Found %d broken links:\n%s' % ( 26 'Warning: Found %d broken links:\n%s' % (
26 len(broken_links), StringifyBrokenLinks(broken_links))) 27 len(broken_links), StringifyBrokenLinks(broken_links)))
27 28
28 def TestOrphanedPages(self): 29 def TestOrphanedPages(self):
29 orphaned_pages = self.link_error_detector.GetOrphanedPages() 30 orphaned_pages = self.link_error_detector.GetOrphanedPages()
30 return ( 31 return (
31 len(orphaned_pages), 32 len(orphaned_pages),
32 'Warning: Found %d orphaned pages:\n%s' % ( 33 'Warning: Found %d orphaned pages:\n%s' % (
33 len(orphaned_pages), '\n'.join(orphaned_pages))) 34 len(orphaned_pages), '\n'.join(orphaned_pages)))
34 35
36
35 class TestServlet(Servlet): 37 class TestServlet(Servlet):
36 '''Runs tests against the live server. Supports running all broken link 38 '''Runs tests against the live server. Supports running all broken link
37 detection tests, in parts or all at once. 39 detection tests, in parts or all at once.
38 ''' 40 '''
39 def __init__(self, request, delegate_for_test=None): 41 def __init__(self, request, delegate_for_test=None):
40 Servlet.__init__(self, request) 42 Servlet.__init__(self, request)
41 self._delegate = delegate_for_test or InstanceServlet.Delegate() 43 self._delegate = delegate_for_test or InstanceServlet.Delegate()
42 44
43 def Get(self): 45 def Get(self):
44 link_error_tests = ('broken_links', 'orphaned_pages', 'link_errors') 46 link_error_tests = ('broken_links', 'orphaned_pages', 'link_errors')
(...skipping 17 matching lines...) Expand all
62 else: 64 else:
63 link_errors, link_content = link_tester.TestBrokenLinks() 65 link_errors, link_content = link_tester.TestBrokenLinks()
64 orphaned_errors, orphaned_content = link_tester.TestOrphanedPages() 66 orphaned_errors, orphaned_content = link_tester.TestOrphanedPages()
65 errors = link_errors + orphaned_errors 67 errors = link_errors + orphaned_errors
66 content = "%s\n%s" % (link_content, orphaned_content) 68 content = "%s\n%s" % (link_content, orphaned_content)
67 69
68 if errors: 70 if errors:
69 return Response.InternalError(content=content) 71 return Response.InternalError(content=content)
70 72
71 return Response.Ok(content="%s test passed." % self._request.path) 73 return Response.Ok(content="%s test passed." % self._request.path)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/test_file_system_test.py ('k') | chrome/common/extensions/docs/server2/test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698