OLD | NEW |
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 instance_servlet import InstanceServlet, OfflineRenderServletDelegate | 5 from instance_servlet import InstanceServlet, OfflineRenderServletDelegate |
6 from link_error_detector import LinkErrorDetector, StringifyBrokenLinks | 6 from link_error_detector import LinkErrorDetector, StringifyBrokenLinks |
7 from servlet import Request, Response, Servlet | 7 from servlet import Request, Response, Servlet |
8 import svn_constants | 8 import svn_constants |
9 | 9 |
10 class BrokenLinkTester(object): | 10 class BrokenLinkTester(object): |
11 '''Run link error detector tests. | 11 '''Run link error detector tests. |
12 ''' | 12 ''' |
13 def __init__(self, server_instance, renderer): | 13 def __init__(self, server_instance, renderer): |
14 self.link_error_detector = LinkErrorDetector( | 14 self.link_error_detector = LinkErrorDetector( |
15 server_instance.host_file_system, | 15 server_instance.host_file_system_provider.GetTrunk(), |
16 renderer, | 16 renderer, |
17 svn_constants.PUBLIC_TEMPLATE_PATH, | 17 svn_constants.PUBLIC_TEMPLATE_PATH, |
18 root_pages=('extensions/index.html', 'apps/about_apps.html')) | 18 root_pages=('extensions/index.html', 'apps/about_apps.html')) |
19 | 19 |
20 def TestBrokenLinks(self): | 20 def TestBrokenLinks(self): |
21 broken_links = self.link_error_detector.GetBrokenLinks() | 21 broken_links = self.link_error_detector.GetBrokenLinks() |
22 return ( | 22 return ( |
23 len(broken_links), | 23 len(broken_links), |
24 'Warning: Found %d broken links:\n%s' % ( | 24 'Warning: Found %d broken links:\n%s' % ( |
25 len(broken_links), StringifyBrokenLinks(broken_links))) | 25 len(broken_links), StringifyBrokenLinks(broken_links))) |
26 | 26 |
27 def TestOrphanedPages(self): | 27 def TestOrphanedPages(self): |
28 orphaned_pages = self.link_error_detector.GetOrphanedPages() | 28 orphaned_pages = self.link_error_detector.GetOrphanedPages() |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 else: | 60 else: |
61 link_errors, link_content = link_tester.TestBrokenLinks() | 61 link_errors, link_content = link_tester.TestBrokenLinks() |
62 orphaned_errors, orphaned_content = link_tester.TestOrphanedPages() | 62 orphaned_errors, orphaned_content = link_tester.TestOrphanedPages() |
63 errors = link_errors + orphaned_errors | 63 errors = link_errors + orphaned_errors |
64 content = "%s\n%s" % (link_content, orphaned_content) | 64 content = "%s\n%s" % (link_content, orphaned_content) |
65 | 65 |
66 if errors: | 66 if errors: |
67 return Response.InternalError(content=content) | 67 return Response.InternalError(content=content) |
68 | 68 |
69 return Response.Ok(content="%s test passed." % self._request.path) | 69 return Response.Ok(content="%s test passed." % self._request.path) |
OLD | NEW |