@@ -62,8 +62,8 @@ class BaseVisionTestCase(unittest.TestCase):
62
62
def _assert_coordinate (self , coordinate ):
63
63
if coordinate is None :
64
64
return
65
+ self .assertIsNotNone (coordinate )
65
66
self .assertIsInstance (coordinate , (int , float ))
66
- self .assertNotEqual (coordinate , 0.0 )
67
67
68
68
def _assert_likelihood (self , likelihood ):
69
69
from google .cloud .vision .likelihood import Likelihood
@@ -73,8 +73,8 @@ 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 :
76
+ def _pb_not_implemented_skip (self , message ):
77
+ if Config .CLIENT ._use_gax :
78
78
self .skipTest (message )
79
79
80
80
@@ -150,7 +150,7 @@ def _assert_landmarks(self, landmarks):
150
150
151
151
for landmark in LandmarkTypes :
152
152
if landmark is not LandmarkTypes .UNKNOWN_LANDMARK :
153
- feature = getattr (landmarks , landmark .value .lower ())
153
+ feature = getattr (landmarks , landmark .name .lower ())
154
154
self .assertIsInstance (feature , Landmark )
155
155
self .assertIsInstance (feature .position , Position )
156
156
self ._assert_coordinate (feature .position .x_coordinate )
@@ -194,7 +194,6 @@ def _assert_face(self, face):
194
194
195
195
def test_detect_faces_content (self ):
196
196
client = Config .CLIENT
197
- self ._maybe_http_skip ('gRPC is required for face detection.' )
198
197
with open (FACE_FILE , 'rb' ) as image_file :
199
198
image = client .image (content = image_file .read ())
200
199
faces = image .detect_faces ()
@@ -203,7 +202,6 @@ def test_detect_faces_content(self):
203
202
self ._assert_face (face )
204
203
205
204
def test_detect_faces_gcs (self ):
206
- self ._maybe_http_skip ('gRPC is required for face detection.' )
207
205
bucket_name = Config .TEST_BUCKET .name
208
206
blob_name = 'faces.jpg'
209
207
blob = Config .TEST_BUCKET .blob (blob_name )
@@ -220,7 +218,6 @@ def test_detect_faces_gcs(self):
220
218
self ._assert_face (face )
221
219
222
220
def test_detect_faces_filename (self ):
223
- self ._maybe_http_skip ('gRPC is required for face detection.' )
224
221
client = Config .CLIENT
225
222
image = client .image (filename = FACE_FILE )
226
223
faces = image .detect_faces ()
@@ -367,7 +364,8 @@ def _assert_safe_search(self, safe_search):
367
364
self ._assert_likelihood (safe_search .violence )
368
365
369
366
def test_detect_safe_search_content (self ):
370
- self ._maybe_http_skip ('gRPC is required for safe search detection.' )
367
+ self ._pb_not_implemented_skip (
368
+ 'gRPC not implemented for safe search detection.' )
371
369
client = Config .CLIENT
372
370
with open (FACE_FILE , 'rb' ) as image_file :
373
371
image = client .image (content = image_file .read ())
@@ -377,7 +375,8 @@ def test_detect_safe_search_content(self):
377
375
self ._assert_safe_search (safe_search )
378
376
379
377
def test_detect_safe_search_gcs (self ):
380
- self ._maybe_http_skip ('gRPC is required for safe search detection.' )
378
+ self ._pb_not_implemented_skip (
379
+ 'gRPC not implemented for safe search detection.' )
381
380
bucket_name = Config .TEST_BUCKET .name
382
381
blob_name = 'faces.jpg'
383
382
blob = Config .TEST_BUCKET .blob (blob_name )
@@ -395,7 +394,8 @@ def test_detect_safe_search_gcs(self):
395
394
self ._assert_safe_search (safe_search )
396
395
397
396
def test_detect_safe_search_filename (self ):
398
- self ._maybe_http_skip ('gRPC is required for safe search detection.' )
397
+ self ._pb_not_implemented_skip (
398
+ 'gRPC not implemented for safe search detection.' )
399
399
client = Config .CLIENT
400
400
image = client .image (filename = FACE_FILE )
401
401
safe_searches = image .detect_safe_search ()
@@ -493,7 +493,8 @@ def _assert_properties(self, image_property):
493
493
self .assertNotEqual (color_info .score , 0.0 )
494
494
495
495
def test_detect_properties_content (self ):
496
- self ._maybe_http_skip ('gRPC is required for text detection.' )
496
+ self ._pb_not_implemented_skip (
497
+ 'gRPC not implemented for image properties detection.' )
497
498
client = Config .CLIENT
498
499
with open (FACE_FILE , 'rb' ) as image_file :
499
500
image = client .image (content = image_file .read ())
@@ -503,7 +504,8 @@ def test_detect_properties_content(self):
503
504
self ._assert_properties (image_property )
504
505
505
506
def test_detect_properties_gcs (self ):
506
- self ._maybe_http_skip ('gRPC is required for text detection.' )
507
+ self ._pb_not_implemented_skip (
508
+ 'gRPC not implemented for image properties detection.' )
507
509
client = Config .CLIENT
508
510
bucket_name = Config .TEST_BUCKET .name
509
511
blob_name = 'faces.jpg'
@@ -521,7 +523,8 @@ def test_detect_properties_gcs(self):
521
523
self ._assert_properties (image_property )
522
524
523
525
def test_detect_properties_filename (self ):
524
- self ._maybe_http_skip ('gRPC is required for text detection.' )
526
+ self ._pb_not_implemented_skip (
527
+ 'gRPC not implemented for image properties detection.' )
525
528
client = Config .CLIENT
526
529
image = client .image (filename = FACE_FILE )
527
530
properties = image .detect_properties ()
0 commit comments