def test_gapic_credentials(self): from google.cloud.gapic.vision.v1.image_annotator_client import ( ImageAnnotatorClient) from google.cloud.vision import Client # Mock the GAPIC ImageAnnotatorClient, whose arguments we # want to check. with mock.patch.object(ImageAnnotatorClient, '__init__') as iac: iac.return_value = None # Create the GAX client. credentials = _make_credentials() client = Client(credentials=credentials, project='foo') self._make_one(client=client) # Assert that the GAPIC constructor was called once, and # that the credentials were sent. iac.assert_called_once() _, _, kwargs = iac.mock_calls[0] self.assertIs(kwargs['credentials'], credentials)
def test_kwarg_lib_name(self): from google.cloud.vision_v1.gapic.image_annotator_client import ( ImageAnnotatorClient) from google.cloud.vision import __version__ from google.cloud.vision import Client # Mock the GAPIC ImageAnnotatorClient, whose arguments we # want to check. with mock.patch.object(ImageAnnotatorClient, '__init__') as iac: iac.return_value = None # Create the GAX client. client = Client(credentials=_make_credentials(), project='foo') self._make_one(client=client) # Assert that the GAPIC constructor was called once, and # that lib_name and lib_version were sent. iac.assert_called_once() _, _, kwargs = iac.mock_calls[0] self.assertEqual(kwargs['lib_name'], 'gccl') self.assertEqual(kwargs['lib_version'], __version__)