OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from testing_utils import testing |
| 6 |
| 7 import common |
| 8 |
| 9 |
| 10 class CommonTest(testing.AppengineTestCase): |
| 11 def test_get_data(self): |
| 12 self.assertIsNone(common.get_data()) |
| 13 |
| 14 data = common.MonAcqData() |
| 15 class MonAcqMock(object): |
| 16 @classmethod |
| 17 def get_by_id(cls, _key): |
| 18 return data |
| 19 |
| 20 self.mock(common, 'MonAcqData', MonAcqMock) |
| 21 self.assertIsInstance(common.get_data(), dict) |
| 22 |
| 23 def test_get_credentials(self): |
| 24 class CredentialsMock(object): |
| 25 def __init__(self, **kwargs): |
| 26 pass |
| 27 import oauth2client.client |
| 28 self.mock(oauth2client.client, 'SignedJwtAssertionCredentials', |
| 29 CredentialsMock) |
| 30 creds = { |
| 31 'client_email': 'we@you.me', |
| 32 'client_id': 'agent007', |
| 33 'private_key': 'deadbeafyoudneverguess', |
| 34 'private_key_id': '!@#$%', |
| 35 } |
| 36 scopes = ['this', 'that'] |
| 37 self.assertIsInstance(common.get_credentials(creds, scopes), object) |
| 38 |
| 39 def test_payload_stats(self): |
| 40 data = 'c00kedbeef' |
| 41 res = "type=<type 'str'>, 10 bytes, md5=407ab662183805731696989975459a9f" |
| 42 self.assertEquals(res, common.payload_stats(data)) |
| 43 |
OLD | NEW |