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

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

Issue 14856006: Docserver: achieve online vs offline (cron vs instance) behaviour at the object (Closed) Base URL: svn://svn.chromium.org/chrome/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 | 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
11 import sys
11 12
12 import appengine_wrappers 13 import appengine_wrappers
13 from file_system import FileNotFoundError 14 from file_system import FileNotFoundError
14 import url_constants 15 import url_constants
15 16
16 class _FakeFetcher(object): 17 class _FakeFetcher(object):
17 def __init__(self, base_path): 18 def __init__(self, base_path):
18 self._base_path = base_path 19 self._base_path = base_path
19 20
20 def _ReadFile(self, path, mode='rb'): 21 def _ReadFile(self, path, mode='rb'):
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 'github_file_system', 102 'github_file_system',
102 'apps_samples.zip'), 103 'apps_samples.zip'),
103 mode='rb') 104 mode='rb')
104 except IOError: 105 except IOError:
105 return None 106 return None
106 107
107 class FakeIssuesFetcher(_FakeFetcher): 108 class FakeIssuesFetcher(_FakeFetcher):
108 def fetch(self, url): 109 def fetch(self, url):
109 return 'Status,Summary,ID' 110 return 'Status,Summary,ID'
110 111
111 def ConfigureFakeFetchers(docs): 112 def ConfigureFakeFetchers():
112 '''Configure the fake fetcher paths relative to the docs directory. 113 '''Configure the fake fetcher paths relative to the docs directory.
113 ''' 114 '''
115 docs = '/'.join((sys.path[0], os.pardir))
114 appengine_wrappers.ConfigureFakeUrlFetch({ 116 appengine_wrappers.ConfigureFakeUrlFetch({
115 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), 117 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs),
116 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), 118 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs),
117 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), 119 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs),
118 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), 120 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs),
119 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), 121 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs),
120 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), 122 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs),
121 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) 123 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs)
122 }) 124 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698