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

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

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: add executable bits for tests Created 7 years, 7 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 # These are fake fetchers that are used for testing and the preview server. 5 # These are fake fetchers that are used for testing and the preview server.
6 # They return canned responses for URLs. appengine_wrappers.py uses the fake 6 # They return canned responses for URLs. appengine_wrappers.py uses the fake
7 # fetchers if the App Engine imports fail. 7 # fetchers if the App Engine imports fail.
8 8
9 import os 9 import os
10 import re 10 import re
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 def fetch(self, url): 100 def fetch(self, url):
101 try: 101 try:
102 return self._ReadFile(os.path.join('server2', 102 return self._ReadFile(os.path.join('server2',
103 'test_data', 103 'test_data',
104 'github_file_system', 104 'github_file_system',
105 'apps_samples.zip'), 105 'apps_samples.zip'),
106 mode='rb') 106 mode='rb')
107 except IOError: 107 except IOError:
108 return None 108 return None
109 109
110 class FakeIssuesFetcher(_FakeFetcher): 110 class FakeRietveldAPI(_FakeFetcher):
111 def __init__(self, base_path):
112 _FakeFetcher.__init__(self, base_path)
113 self._base_pattern = re.compile(r'.*/(api/.*)')
114
111 def fetch(self, url): 115 def fetch(self, url):
112 return 'Status,Summary,ID' 116 try:
117 return self._ReadFile(
118 os.path.join('server2',
119 'test_data',
120 'rietveld_patcher',
121 self._base_pattern.match(url).group(1),
122 'json'))
123 except IOError:
124 return None
125
126 class FakeRietveldTarball(_FakeFetcher):
127 def __init__(self, base_path):
128 _FakeFetcher.__init__(self, base_path)
129 self._base_pattern = re.compile(r'.*/(tarball/\d+/\d+)')
130
131 def fetch(self, url):
132 try:
133 return self._ReadFile(
134 os.path.join('server2',
135 'test_data',
136 'rietveld_patcher',
137 self._base_pattern.match(url).group(1) + '.tar.bz2'))
138 except IOError:
139 return None
113 140
114 def ConfigureFakeFetchers(): 141 def ConfigureFakeFetchers():
115 '''Configure the fake fetcher paths relative to the docs directory. 142 '''Configure the fake fetcher paths relative to the docs directory.
116 ''' 143 '''
117 docs = '/'.join((sys.path[0], os.pardir)) 144 docs = '/'.join((sys.path[0], os.pardir))
118 appengine_wrappers.ConfigureFakeUrlFetch({ 145 appengine_wrappers.ConfigureFakeUrlFetch({
119 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), 146 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs),
120 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), 147 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs),
121 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), 148 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs),
122 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), 149 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs),
123 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), 150 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs),
124 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), 151 '%s/api/.*' % url_constants.CODEREVIEW_SERVER: FakeRietveldAPI(docs),
125 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) 152 '%s/tarball/.*' % url_constants.CODEREVIEW_SERVER:
153 FakeRietveldTarball(docs),
126 }) 154 })
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron_servlet.py ('k') | chrome/common/extensions/docs/server2/handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698