Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba05fca

Browse filesBrowse files
committed
Mock ImageAnnotatorClient to pass travis.
1 parent 3bdd57e commit ba05fca
Copy full SHA for ba05fca

File tree

Expand file treeCollapse file tree

2 files changed

+7
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-13
lines changed
Open diff view settings
Collapse file

‎vision/unit_tests/test__gax.py‎

Copy file name to clipboardExpand all lines: vision/unit_tests/test__gax.py
+4-11Lines 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):
Collapse file

‎vision/unit_tests/test_client.py‎

Copy file name to clipboardExpand all lines: vision/unit_tests/test_client.py
+3-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.