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

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

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finding earliest 'stable' availability using features files Created 7 years, 8 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 19 matching lines...) Expand all
30 def _Stat(self, path): 30 def _Stat(self, path):
31 return int(os.stat(os.path.join(self._base_path, path)).st_mtime) 31 return int(os.stat(os.path.join(self._base_path, path)).st_mtime)
32 32
33 class FakeOmahaProxy(_FakeFetcher): 33 class FakeOmahaProxy(_FakeFetcher):
34 def fetch(self, url): 34 def fetch(self, url):
35 return self._ReadFile(os.path.join('server2', 35 return self._ReadFile(os.path.join('server2',
36 'test_data', 36 'test_data',
37 'branch_utility', 37 'branch_utility',
38 'first.json')) 38 'first.json'))
39 39
40 class FakeOmahaHistory(_FakeFetcher):
41 def fetch(self, url):
42 return self._ReadFile(os.path.join('server2',
43 'test_data',
44 'chrome_version_utility',
45 'omaha_dev_win_history.json'))
46
40 class FakeSubversionServer(_FakeFetcher): 47 class FakeSubversionServer(_FakeFetcher):
41 def __init__(self, base_path): 48 def __init__(self, base_path):
42 _FakeFetcher.__init__(self, base_path) 49 _FakeFetcher.__init__(self, base_path)
43 self._base_pattern = re.compile(r'.*chrome/common/extensions/(.*)') 50 self._base_pattern = re.compile(r'.*chrome/common/extensions/(.*)')
44 51
45 def fetch(self, url): 52 def fetch(self, url):
46 path = os.path.join(os.pardir, self._base_pattern.match(url).group(1)) 53 path = os.path.join(os.pardir, self._base_pattern.match(url).group(1))
47 if self._IsDir(path): 54 if self._IsDir(path):
48 html = ['<html>Revision 000000'] 55 html = ['<html>Revision 000000']
49 try: 56 try:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 113
107 class FakeIssuesFetcher(_FakeFetcher): 114 class FakeIssuesFetcher(_FakeFetcher):
108 def fetch(self, url): 115 def fetch(self, url):
109 return 'Status,Summary,ID' 116 return 'Status,Summary,ID'
110 117
111 def ConfigureFakeFetchers(docs): 118 def ConfigureFakeFetchers(docs):
112 '''Configure the fake fetcher paths relative to the docs directory. 119 '''Configure the fake fetcher paths relative to the docs directory.
113 ''' 120 '''
114 appengine_wrappers.ConfigureFakeUrlFetch({ 121 appengine_wrappers.ConfigureFakeUrlFetch({
115 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), 122 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs),
123 re.escape(url_constants.OMAHA_DEV_HISTORY): FakeOmahaHistory(docs),
116 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), 124 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs),
117 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), 125 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs),
118 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), 126 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs),
119 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), 127 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs),
120 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), 128 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs),
121 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) 129 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs)
122 }) 130 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698