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

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

Issue 82433002: Docserver: Further refactoring to the new GithubFileSystem to make it update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix test data Created 7 years 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 (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 html.append('</tbody></table>') 100 html.append('</tbody></table>')
101 return '\n'.join(html) 101 return '\n'.join(html)
102 try: 102 try:
103 return ReadFile(path) 103 return ReadFile(path)
104 except IOError: 104 except IOError:
105 return None 105 return None
106 106
107 107
108 class _FakeGithubStat(_FakeFetcher): 108 class _FakeGithubStat(_FakeFetcher):
109 def fetch(self, url): 109 def fetch(self, url):
110 return '{ "commit": { "tree": { "sha": 0} } }' 110 return '{ "commit": { "sha": 0} }'
111 111
112 112
113 class _FakeGithubZip(_FakeFetcher): 113 class _FakeGithubZip(_FakeFetcher):
114 def fetch(self, url): 114 def fetch(self, url):
115 return _ReadTestData('github_file_system', 'apps_samples.zip', mode='rb') 115 return _ReadTestData('github_file_system', 'apps_samples.zip', mode='rb')
116 116
117 117
118 class _FakeRietveldAPI(_FakeFetcher): 118 class _FakeRietveldAPI(_FakeFetcher):
119 def __init__(self): 119 def __init__(self):
120 self._base_pattern = re.compile(r'.*/(api/.*)') 120 self._base_pattern = re.compile(r'.*/(api/.*)')
(...skipping 19 matching lines...) Expand all
140 appengine_wrappers.ConfigureFakeUrlFetch({ 140 appengine_wrappers.ConfigureFakeUrlFetch({
141 url_constants.OMAHA_PROXY_URL: _FakeOmahaProxy(), 141 url_constants.OMAHA_PROXY_URL: _FakeOmahaProxy(),
142 re.escape(url_constants.OMAHA_DEV_HISTORY): _FakeOmahaHistory(), 142 re.escape(url_constants.OMAHA_DEV_HISTORY): _FakeOmahaHistory(),
143 '%s/.*' % url_constants.SVN_URL: _FakeSubversionServer(), 143 '%s/.*' % url_constants.SVN_URL: _FakeSubversionServer(),
144 '%s/.*' % url_constants.VIEWVC_URL: _FakeViewvcServer(), 144 '%s/.*' % url_constants.VIEWVC_URL: _FakeViewvcServer(),
145 '%s/.*/commits/.*' % url_constants.GITHUB_REPOS: _FakeGithubStat(), 145 '%s/.*/commits/.*' % url_constants.GITHUB_REPOS: _FakeGithubStat(),
146 '%s/.*/zipball' % url_constants.GITHUB_REPOS: _FakeGithubZip(), 146 '%s/.*/zipball' % url_constants.GITHUB_REPOS: _FakeGithubZip(),
147 '%s/api/.*' % url_constants.CODEREVIEW_SERVER: _FakeRietveldAPI(), 147 '%s/api/.*' % url_constants.CODEREVIEW_SERVER: _FakeRietveldAPI(),
148 '%s/tarball/.*' % url_constants.CODEREVIEW_SERVER: _FakeRietveldTarball(), 148 '%s/tarball/.*' % url_constants.CODEREVIEW_SERVER: _FakeRietveldTarball(),
149 }) 149 })
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron.yaml ('k') | chrome/common/extensions/docs/server2/file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698