Skip to content

Commit ba05fca

Browse files
committed
Mock ImageAnnotatorClient to pass travis.
1 parent 3bdd57e commit ba05fca

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

vision/unit_tests/test__gax.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
import mock
1818

1919

20-
def _make_credentials():
21-
import google.auth.credentials
22-
return mock.Mock(spec=google.auth.credentials.Credentials)
23-
24-
2520
class TestGAXClient(unittest.TestCase):
2621
def _get_target_class(self):
2722
from google.cloud.vision._gax import _GAPICVisionAPI
@@ -31,13 +26,11 @@ def _make_one(self, *args, **kwargs):
3126
return self._get_target_class()(*args, **kwargs)
3227

3328
def test_ctor(self):
34-
from google.cloud.gapic.vision.v1 import image_annotator_client
35-
36-
client = mock.Mock(credentials=_make_credentials())
37-
api = self._make_one(client)
29+
client = mock.Mock()
30+
with mock.patch('google.cloud.vision._gax.image_annotator_client.'
31+
'ImageAnnotatorClient'):
32+
api = self._make_one(client)
3833
self.assertIs(api._client, client)
39-
self.assertIsInstance(api._api,
40-
image_annotator_client.ImageAnnotatorClient)
4134

4235

4336
class TestToGAPICFeature(unittest.TestCase):

vision/unit_tests/test_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def test_make_gax_client(self):
5959
from google.cloud.vision._gax import _GAPICVisionAPI
6060

6161
credentials = _make_credentials()
62-
client = self._make_one(project=PROJECT, credentials=credentials,
63-
use_gax=None)
62+
with mock.patch('google.cloud.vision.client._GAPICVisionAPI'):
63+
client = self._make_one(project=PROJECT, credentials=credentials,
64+
use_gax=None)
6465
client._connection = _Connection()
6566
self.assertIsInstance(client._vision_api, _GAPICVisionAPI)
6667

0 commit comments

Comments
 (0)