Exemplo n.º 1
0
# Copyright 2015 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.
"""Mocks out oauth2_decorator for unit testing."""

from apiclient import http
from dashboard import oauth2_decorator

HTTP_MOCK = http.HttpMock(headers={'status': '200'})


class MockOAuth2Decorator(object):
    """Mocks OAuth2Decorator for testing."""

    # This list will be used to keep a copy of the mocked http requests' bodies.
    # Note that this is a class variable because it may not be easy to get the
    # particular instance of the decorator used.
    past_bodies = []

    def __init__(self, client_id, client_secret, scope, message,
                 callback_path):
        self.client_id = client_id
        self.client_secret = client_secret
        self.scope = scope
        self.message = message
        self.callback_path = callback_path

    def http(self):
        # The body attribute is set after this is returned, so all we can do here
        # is to save the previous one before it's overriden.
        MockOAuth2Decorator.past_bodies.append(HTTP_MOCK.body)
Exemplo n.º 2
0
 def http(self):
     return http.HttpMock(headers={'status': '200'})