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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/fake_fetchers.py
===================================================================
--- chrome/common/extensions/docs/server2/fake_fetchers.py (revision 198562)
+++ chrome/common/extensions/docs/server2/fake_fetchers.py (working copy)
@@ -104,10 +104,37 @@
except IOError:
return None
-class FakeIssuesFetcher(_FakeFetcher):
+class FakeRietveldAPI(_FakeFetcher):
+ def __init__(self, base_path):
+ _FakeFetcher.__init__(self, base_path)
+ self._base_pattern = re.compile(r'.*/(api/.*)')
+
def fetch(self, url):
- return 'Status,Summary,ID'
+ try:
+ return self._ReadFile(
+ os.path.join('server2',
+ 'test_data',
+ 'rietveld_patcher',
+ self._base_pattern.match(url).group(1),
+ 'json'))
+ except IOError:
+ return None
+class FakeRietveldTarball(_FakeFetcher):
+ def __init__(self, base_path):
+ _FakeFetcher.__init__(self, base_path)
+ self._base_pattern = re.compile(r'.*/(tarball/\d+/\d+)')
+
+ def fetch(self, url):
+ try:
+ return self._ReadFile(
+ os.path.join('server2',
+ 'test_data',
+ 'rietveld_patcher',
+ self._base_pattern.match(url).group(1) + '.tar.bz2'))
+ except IOError:
+ return None
+
def ConfigureFakeFetchers(docs):
'''Configure the fake fetcher paths relative to the docs directory.
'''
@@ -117,6 +144,7 @@
'%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs),
'%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs),
'%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs),
- re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs),
- re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs)
+ '%s/api/.*' % url_constants.CODEREVIEW_SERVER: FakeRietveldAPI(docs),
+ '%s/tarball/.*' % url_constants.CODEREVIEW_SERVER:
+ FakeRietveldTarball(docs),
})

Powered by Google App Engine
This is Rietveld 408576698