| Index: appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/test/testing_common.py
|
| diff --git a/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/test/testing_common.py b/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/test/testing_common.py
|
| deleted file mode 100644
|
| index 8dbc9035ab78446bb6c366f0836355a6fd6019b6..0000000000000000000000000000000000000000
|
| --- a/appengine_apps/trooper_o_matic/appengine_module/trooper_o_matic/test/testing_common.py
|
| +++ /dev/null
|
| @@ -1,36 +0,0 @@
|
| -# Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| -# Use of this source code is governed by a BSD-style license that can be
|
| -# found in the LICENSE file.
|
| -
|
| -"""Common functions for unit tests."""
|
| -from google.appengine.api import apiproxy_stub
|
| -from google.appengine.api import apiproxy_stub_map
|
| -
|
| -
|
| -def StubUrlfetch(responses, stub=None): # pragma: no cover
|
| - """Stub out url fetch for unit tests.
|
| -
|
| - Args:
|
| - responses: Dict mapping url -> dict of response 'content', 'statuscode'
|
| - stub: apiproxy_stub.APIProxyStub used to stub out urlfetch, if using testbed
|
| - """
|
| - fetch_mock = FetchServiceMock(responses)
|
| - if stub:
|
| - # pylint: disable=W0212
|
| - stub._Dynamic_Fetch = fetch_mock._Dynamic_Fetch
|
| - else:
|
| - apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', fetch_mock)
|
| -
|
| -
|
| -class FetchServiceMock(apiproxy_stub.APIProxyStub): # pragma: no cover
|
| - """Mock URLFetch service used byt StubUrlfetch."""
|
| -
|
| - def __init__(self, responses):
|
| - self.responses = responses
|
| - super(FetchServiceMock, self).__init__('urlfetch')
|
| -
|
| - def _Dynamic_Fetch(self, request, response):
|
| - url = request.url()
|
| - assert url in self.responses, '%s unexpected' % url
|
| - response.set_content(self.responses[url]['content'])
|
| - response.set_statuscode(self.responses[url]['statuscode'])
|
|
|