8000 Mock ImageAnnotatorClient to pass travis. · googleapis/google-cloud-python@4d0a912 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d0a912

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

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ 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._gax.image_annotator_client.'
63+
'ImageAnnotatorClient'):
64+
client = self._make_one(project=PROJECT, credentials=credentials,
65+
use_gax=None)
6466
client._connection = _Connection()
6567
self.assertIsInstance(client._vision_api, _GAPICVisionAPI)
6668

0 commit comments

Comments
 (0)
0