Index: chrome/common/extensions/docs/server2/appengine_wrappers.py |
diff --git a/chrome/common/extensions/docs/server2/appengine_wrappers.py b/chrome/common/extensions/docs/server2/appengine_wrappers.py |
index 7fcb7159d5dd3330c8715a3023751e6201369a44..7c0335aea0170bd04971485e0f41534709881693 100644 |
--- a/chrome/common/extensions/docs/server2/appengine_wrappers.py |
+++ b/chrome/common/extensions/docs/server2/appengine_wrappers.py |
@@ -9,17 +9,48 @@ try: |
import google.appengine.api.memcache as memcache |
import google.appengine.api.urlfetch as urlfetch |
except ImportError: |
+ import re |
+ |
+ FAKE_URL_FETCHER_CONFIGURATION = None |
+ |
+ def ConfigureFakeUrlFetch(configuration): |
+ global FAKE_URL_FETCHER_CONFIGURATION |
+ FAKE_URL_FETCHER_CONFIGURATION = dict( |
+ (re.compile(k), v) for k, v in configuration.iteritems()) |
+ |
+ def GetConfiguration(key): |
not at google - send to devlin
2012/08/13 22:36:46
add like
if not FAKE_URL_FETCHER_CONFIGURATION:
cduvall
2012/08/13 23:17:22
Done.
|
+ for k, v in FAKE_URL_FETCHER_CONFIGURATION.iteritems(): |
+ if k.match(key): |
+ return v |
+ return None |
+ |
class FakeUrlFetch(object): |
"""A fake urlfetch module that errors for all method calls. |
not at google - send to devlin
2012/08/13 22:36:46
comment is out of date
cduvall
2012/08/13 23:17:22
Done.
|
""" |
+ class _Response(object): |
+ def __init__(self, content): |
+ self.content = content |
+ self.headers = { 'content-type': 'none' } |
+ self.status_code = 200 |
+ |
+ class _RPC(object): |
+ def __init__(self): |
+ self.result = None |
+ |
+ def wait(self): |
+ pass |
+ |
+ def get_result(self): |
+ return self.result |
+ |
def fetch(self, url): |
- raise NotImplementedError() |
+ return self._Response(GetConfiguration(url).fetch(url)) |
def create_rpc(self): |
- raise NotImplementedError() |
+ return self._RPC() |
- def make_fetch_call(self): |
- raise NotImplementedError() |
+ def make_fetch_call(self, rpc, url): |
+ rpc.result = self.fetch(url) |
urlfetch = FakeUrlFetch() |
class InMemoryMemcache(object): |