Skip to content

Commit

Permalink
Mock ImageAnnotatorClient to pass travis.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Jan 3, 2017
1 parent 3bdd57e commit ba05fca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 4 additions & 11 deletions vision/unit_tests/test__gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
import mock


def _make_credentials():
import google.auth.credentials
return mock.Mock(spec=google.auth.credentials.Credentials)


class TestGAXClient(unittest.TestCase):
def _get_target_class(self):
from google.cloud.vision._gax import _GAPICVisionAPI
Expand All @@ -31,13 +26,11 @@ def _make_one(self, *args, **kwargs):
return self._get_target_class()(*args, **kwargs)

def test_ctor(self):
from google.cloud.gapic.vision.v1 import image_annotator_client

client = mock.Mock(credentials=_make_credentials())
api = self._make_one(client)
client = mock.Mock()
with mock.patch('google.cloud.vision._gax.image_annotator_client.'
'ImageAnnotatorClient'):
api = self._make_one(client)
self.assertIs(api._client, client)
self.assertIsInstance(api._api,
image_annotator_client.ImageAnnotatorClient)


class TestToGAPICFeature(unittest.TestCase):
Expand Down
5 changes: 3 additions & 2 deletions vision/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def test_make_gax_client(self):
from google.cloud.vision._gax import _GAPICVisionAPI

credentials = _make_credentials()
client = self._make_one(project=PROJECT, credentials=credentials,
use_gax=None)
with mock.patch('google.cloud.vision.client._GAPICVisionAPI'):
client = self._make_one(project=PROJECT, credentials=credentials,
use_gax=None)
client._connection = _Connection()
self.assertIsInstance(client._vision_api, _GAPICVisionAPI)

Expand Down

0 comments on commit ba05fca

Please sign in to comment.