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

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: 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 def fetch(self, url): 97 def fetch(self, url):
98 try: 98 try:
99 return self._ReadFile(os.path.join('server2', 99 return self._ReadFile(os.path.join('server2',
100 'test_data', 100 'test_data',
101 'github_file_system', 101 'github_file_system',
102 'apps_samples.zip'), 102 'apps_samples.zip'),
103 mode='rb') 103 mode='rb')
104 except IOError: 104 except IOError:
105 return None 105 return None
106 106
107 class FakeIssuesFetcher(_FakeFetcher): 107 class FakeRietveldAPI(_FakeFetcher):
108 def __init__(self, base_path):
109 _FakeFetcher.__init__(self, base_path)
110 self._base_pattern = re.compile(r'.*/(api/.*)')
111
108 def fetch(self, url): 112 def fetch(self, url):
109 return 'Status,Summary,ID' 113 try:
114 print url
115 return self._ReadFile(
116 os.path.join('server2',
117 'test_data',
118 'rietveld_file_system',
119 self._base_pattern.match(url).group(1),
120 'json'))
121 except IOError:
122 return None
123
124 class FakeRietveldTarball(_FakeFetcher):
125 def __init__(self, base_path):
126 _FakeFetcher.__init__(self, base_path)
127 self._base_pattern = re.compile(r'.*/(tarball/\d+/\d+)')
128
129 def fetch(self, url):
130 try:
131 return self._ReadFile(
132 os.path.join('server2',
133 'test_data',
134 'rietveld_file_system',
135 self._base_pattern.match(url).group(1) + '.tar.bz2'))
136 except IOError:
137 return None
110 138
111 def ConfigureFakeFetchers(docs): 139 def ConfigureFakeFetchers(docs):
112 '''Configure the fake fetcher paths relative to the docs directory. 140 '''Configure the fake fetcher paths relative to the docs directory.
113 ''' 141 '''
114 appengine_wrappers.ConfigureFakeUrlFetch({ 142 appengine_wrappers.ConfigureFakeUrlFetch({
115 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), 143 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs),
116 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), 144 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs),
117 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), 145 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs),
118 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), 146 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs),
119 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), 147 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs),
120 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), 148 '%s/api/.*' % url_constants.CODEREVIEW_SERVER: FakeRietveldAPI(docs),
121 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) 149 '%s/tarball/.*' % url_constants.CODEREVIEW_SERVER:
150 FakeRietveldTarball(docs),
122 }) 151 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698