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

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

Issue 10871002: Extensions Docs Server: Testing GithubFileSystem and cron jobs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small changes Created 8 years, 3 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 | 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 continue 61 continue
62 html.append('<td><a name="%s"></a></td>' % f) 62 html.append('<td><a name="%s"></a></td>' % f)
63 if os.path.isdir(os.path.join(path, f)): 63 if os.path.isdir(os.path.join(path, f)):
64 html.append('<td><a title="dir"><strong>000000</strong></a></td>') 64 html.append('<td><a title="dir"><strong>000000</strong></a></td>')
65 else: 65 else:
66 html.append('<td><a title="file"><strong>000000</strong></a></td>') 66 html.append('<td><a title="file"><strong>000000</strong></a></td>')
67 html.append('</html>') 67 html.append('</html>')
68 return '\n'.join(html) 68 return '\n'.join(html)
69 return _ReadFile(path) 69 return _ReadFile(path)
70 70
71 class FakeGithub(object): 71 class FakeGithubStat(object):
72 def fetch(self, url): 72 def fetch(self, url):
73 return '{ "commit": { "tree": { "sha": 0} } }' 73 return '{ "commit": { "tree": { "sha": 0} } }'
74 74
75 class FakeGithubZip(object):
76 def fetch(self, url):
77 return _ReadFile(os.path.join('test_data',
78 'github_file_system',
79 'apps_samples.zip'))
80
75 def ConfigureFakeFetchers(): 81 def ConfigureFakeFetchers():
76 appengine_wrappers.ConfigureFakeUrlFetch({ 82 appengine_wrappers.ConfigureFakeUrlFetch({
77 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(), 83 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(),
78 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(), 84 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(),
79 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(), 85 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(),
80 '%s/.*' % url_constants.GITHUB_URL: FakeGithub() 86 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(),
87 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip()
81 }) 88 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698