Index: appengine/chrome_infra_mon_proxy/test/common_test.py |
diff --git a/appengine/chrome_infra_mon_proxy/test/common_test.py b/appengine/chrome_infra_mon_proxy/test/common_test.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ee8618d5d33ef0ebbbfc54ef66d20f970c8e9471 |
--- /dev/null |
+++ b/appengine/chrome_infra_mon_proxy/test/common_test.py |
@@ -0,0 +1,43 @@ |
+# 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. |
+ |
+from testing_utils import testing |
+ |
+import common |
+ |
+ |
+class CommonTest(testing.AppengineTestCase): |
+ def test_get_data(self): |
+ self.assertIsNone(common.get_data()) |
+ |
+ data = common.MonAcqData() |
+ class MonAcqMock(object): |
+ @classmethod |
+ def get_by_id(cls, _key): |
+ return data |
+ |
+ self.mock(common, 'MonAcqData', MonAcqMock) |
+ self.assertIsInstance(common.get_data(), dict) |
+ |
+ def test_get_credentials(self): |
+ class CredentialsMock(object): |
+ def __init__(self, **kwargs): |
+ pass |
+ import oauth2client.client |
+ self.mock(oauth2client.client, 'SignedJwtAssertionCredentials', |
+ CredentialsMock) |
+ creds = { |
+ 'client_email': 'we@you.me', |
+ 'client_id': 'agent007', |
+ 'private_key': 'deadbeafyoudneverguess', |
ghost stip (do not use)
2015/04/14 00:36:43
beef? :p
Sergey Berezin (google)
2015/04/16 04:39:07
because chicken is not hex?
|
+ 'private_key_id': '!@#$%', |
+ } |
+ scopes = ['this', 'that'] |
+ self.assertIsInstance(common.get_credentials(creds, scopes), object) |
+ |
+ def test_payload_stats(self): |
+ data = 'c00kedbeef' |
+ res = "type=<type 'str'>, 10 bytes, md5=407ab662183805731696989975459a9f" |
+ self.assertEquals(res, common.payload_stats(data)) |
+ |