1515
1616import unittest
1717
18+ import mock
19+
20+
21+ def _make_credentials ():
22+ import google .auth .credentials
23+ return mock .Mock (spec = google .auth .credentials .Credentials )
24+
1825
1926class TestClient (unittest .TestCase ):
2027
@@ -38,14 +45,14 @@ def _makeHTTP(self, *args, **kw):
3845 VERSION = 'myversion'
3946
4047 def test_ctor_default (self ):
41- CREDENTIALS = object ()
48+ CREDENTIALS = _make_credentials ()
4249 target = self ._make_one (project = self .PROJECT ,
4350 credentials = CREDENTIALS )
4451 self .assertEquals (target .service , target .DEFAULT_SERVICE )
4552 self .assertEquals (target .version , None )
4653
4754 def test_ctor_params (self ):
48- CREDENTIALS = object ()
55+ CREDENTIALS = _make_credentials ()
4956 target = self ._make_one (project = self .PROJECT ,
5057 credentials = CREDENTIALS ,
5158 service = self .SERVICE ,
@@ -54,7 +61,7 @@ def test_ctor_params(self):
5461 self .assertEquals (target .version , self .VERSION )
5562
5663 def test_report_exception (self ):
57- CREDENTIALS = object ()
64+ CREDENTIALS = _make_credentials ()
5865 target = self ._make_one (project = self .PROJECT ,
5966 credentials = CREDENTIALS )
6067
@@ -74,7 +81,7 @@ def test_report_exception(self):
7481 self .assertIn ('test_client.py' , payload ['message' ])
7582
7683 def test_report_exception_with_service_version_in_constructor (self ):
77- CREDENTIALS = object ()
84+ CREDENTIALS = _make_credentials ()
7885 SERVICE = "notdefault"
7986 VERSION = "notdefaultversion"
8087 target = self ._make_one (project = self .PROJECT ,
@@ -109,7 +116,7 @@ def test_report_exception_with_service_version_in_constructor(self):
109116 self .assertEquals (payload ['context' ]['user' ], USER )
110117
111118 def test_report (self ):
112- CREDENTIALS = object ()
119+ CREDENTIALS = _make_credentials ()
113120 target = self ._make_one (project = self .PROJECT ,
114121 credentials = CREDENTIALS )
115122
0 commit comments