@@ -82,6 +82,31 @@ def test_annotate_no_results(self):
82
82
83
83
gax_api ._annotator_client .batch_annotate_images .assert_called ()
84
84
85
+ def test_annotate_multiple_results (self ):
86
+ from google .cloud .vision .feature import Feature
87
+ from google .cloud .vision .feature import FeatureTypes
88
+ from google .cloud .vision .image import Image
89
+
90
+ client = mock .Mock (spec_set = [])
91
+ feature = Feature (FeatureTypes .LABEL_DETECTION , 5 )
92
+ image_content = b'abc 1 2 3'
93
+ image = Image (client , content = image_content )
94
+ with mock .patch ('google.cloud.vision._gax.image_annotator_client.'
95
+ 'ImageAnnotatorClient' ):
96
+ gax_api = self ._make_one (client )
97
+
98
+ mock_response = {
99
+ 'batch_annotate_images.return_value' : mock .Mock (responses = [1 , 2 ]),
100
+ }
101
+
102
+ gax_api ._annotator_client = mock .Mock (
103
+ spec_set = ['batch_annotate_images' ], ** mock_response )
104
+ with mock .patch ('google.cloud.vision._gax.Annotations' ):
105
+ with self .assertRaises (ValueError ):
106
+ gax_api .annotate (image , [feature ])
107
+
108
+ gax_api ._annotator_client .batch_annotate_images .assert_called ()
109
+
85
110
86
111
class Test__to_gapic_feature (unittest .TestCase ):
87
112
def _call_fut (self , feature ):
0 commit comments