| OLD | NEW |
| 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 Loading... |
| 30 def _Stat(self, path): | 30 def _Stat(self, path): |
| 31 return os.stat(os.path.join(self._base_path, path)).st_mtime | 31 return 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_data_source', |
| 45 'omaha_beta_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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 111 |
| 105 class FakeIssuesFetcher(_FakeFetcher): | 112 class FakeIssuesFetcher(_FakeFetcher): |
| 106 def fetch(self, url): | 113 def fetch(self, url): |
| 107 return 'Status,Summary,ID' | 114 return 'Status,Summary,ID' |
| 108 | 115 |
| 109 def ConfigureFakeFetchers(docs): | 116 def ConfigureFakeFetchers(docs): |
| 110 '''Configure the fake fetcher paths relative to the docs directory. | 117 '''Configure the fake fetcher paths relative to the docs directory. |
| 111 ''' | 118 ''' |
| 112 appengine_wrappers.ConfigureFakeUrlFetch({ | 119 appengine_wrappers.ConfigureFakeUrlFetch({ |
| 113 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), | 120 url_constants.OMAHA_PROXY_URL: FakeOmahaProxy(docs), |
| 121 re.escape(url_constants.OMAHA_BETA_HISTORY): FakeOmahaHistory(docs), |
| 114 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), | 122 '%s/.*' % url_constants.SVN_URL: FakeSubversionServer(docs), |
| 115 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), | 123 '%s/.*' % url_constants.VIEWVC_URL: FakeViewvcServer(docs), |
| 116 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), | 124 '%s/commits/.*' % url_constants.GITHUB_URL: FakeGithubStat(docs), |
| 117 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), | 125 '%s/zipball' % url_constants.GITHUB_URL: FakeGithubZip(docs), |
| 118 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), | 126 re.escape(url_constants.OPEN_ISSUES_CSV_URL): FakeIssuesFetcher(docs), |
| 119 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) | 127 re.escape(url_constants.CLOSED_ISSUES_CSV_URL): FakeIssuesFetcher(docs) |
| 120 }) | 128 }) |
| OLD | NEW |