@@ -73,6 +73,10 @@ def _assert_likelihood(self, likelihood):
73
73
Likelihood .VERY_UNLIKELY ]
74
74
self .assertIn (likelihood , levels )
75
75
76
+ def _maybe_http_skip (self , message ):
77
+ if not Config .CLIENT ._use_gax :
78
+ self .skipTest (message )
79
+
76
80
77
81
class TestVisionClientLogo (unittest .TestCase ):
78
82
def setUp (self ):
@@ -190,6 +194,7 @@ def _assert_face(self, face):
190
194
191
195
def test_detect_faces_content (self ):
192
196
client = Config .CLIENT
197
+ self ._maybe_http_skip ('gRPC is required for face detection.' )
193
198
with open (FACE_FILE , 'rb' ) as image_file :
194
199
image = client .image (content = image_file .read ())
195
200
faces = image .detect_faces ()
@@ -198,6 +203,7 @@ def test_detect_faces_content(self):
198
203
self ._assert_face (face )
199
204
200
205
def test_detect_faces_gcs (self ):
206
+ self ._maybe_http_skip ('gRPC is required for face detection.' )
201
207
bucket_name = Config .TEST_BUCKET .name
202
208
blob_name = 'faces.jpg'
203
209
blob = Config .TEST_BUCKET .blob (blob_name )
@@ -206,7 +212,6 @@ def test_detect_faces_gcs(self):
206
212
blob .upload_from_file (file_obj )
207
213
208
214
source_uri = 'gs://%s/%s' % (bucket_name , blob_name )
209
-
210
215
client = Config .CLIENT
211
216
image = client .image (source_uri = source_uri )
212
217
faces = image .detect_faces ()
@@ -215,6 +220,7 @@ def test_detect_faces_gcs(self):
215
220
self ._assert_face (face )
216
221
217
222
def test_detect_faces_filename (self ):
223
+ self ._maybe_http_skip ('gRPC is required for face detection.' )
218
224
client = Config .CLIENT
219
225
image = client .image (filename = FACE_FILE )
220
226
faces = image .detect_faces ()
@@ -361,6 +367,7 @@ def _assert_safe_search(self, safe_search):
361
367
self ._assert_likelihood (safe_search .violence )
362
368
363
369
def test_detect_safe_search_content (self ):
370
+ self ._maybe_http_skip ('gRPC is required for safe search detection.' )
364
371
client = Config .CLIENT
365
372
with open (FACE_FILE , 'rb' ) as image_file :
366
373
image = client .image (content = image_file .read ())
@@ -370,6 +377,7 @@ def test_detect_safe_search_content(self):
370
377
self ._assert_safe_search (safe_search )
371
378
372
379
def test_detect_safe_search_gcs (self ):
380
+ self ._maybe_http_skip ('gRPC is required for safe search detection.' )
373
381
bucket_name = Config .TEST_BUCKET .name
374
382
blob_name = 'faces.jpg'
375
383
blob = Config .TEST_BUCKET .blob (blob_name )
@@ -387,6 +395,7 @@ def test_detect_safe_search_gcs(self):
387
395
self ._assert_safe_search (safe_search )
388
396
389
397
def test_detect_safe_search_filename (self ):
398
+ self ._maybe_http_skip ('gRPC is required for safe search detection.' )
390
399
client = Config .CLIENT
391
400
image = client .image (filename = FACE_FILE )
392
401
safe_searches = image .detect_safe_search ()
@@ -484,6 +493,7 @@ def _assert_properties(self, image_property):
484
493
self .assertNotEqual (color_info .score , 0.0 )
485
494
486
495
def test_detect_properties_content (self ):
496
+ self ._maybe_http_skip ('gRPC is required for text detection.' )
487
497
client = Config .CLIENT
488
498
with open (FACE_FILE , 'rb' ) as image_file :
489
499
image = client .image (content = image_file .read ())
@@ -493,6 +503,8 @@ def test_detect_properties_content(self):
493
503
self ._assert_properties (image_property )
494
504
495
505
def test_detect_properties_gcs (self ):
506
+ self ._maybe_http_skip ('gRPC is required for text detection.' )
507
+ client = Config .CLIENT
496
508
bucket_name = Config .TEST_BUCKET .name
497
509
blob_name = 'faces.jpg'
498
510
blob = Config .TEST_BUCKET .blob (blob_name )
@@ -502,14 +514,14 @@ def test_detect_properties_gcs(self):
502
514
503
515
source_uri = 'gs://%s/%s' % (bucket_name , blob_name )
504
516
505
- client = Config .CLIENT
506
517
image = client .image (source_uri = source_uri )
507
518
properties = image .detect_properties ()
508
519
self .assertEqual (len (properties ), 1 )
509
520
image_property = properties [0 ]
510
521
self ._assert_properties (image_property )
511
522
512
523
def test_detect_properties_filename (self ):
524
+ self ._maybe_http_skip ('gRPC is required for text detection.' )
513
525
client = Config .CLIENT
514
526
image = client .image (filename = FACE_FILE )
515
527
properties = image .detect_properties ()
0 commit comments