Skip to content

Commit

Permalink
Update system tests and set client back to normal.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Jan 16, 2017
1 parent 20d6d59 commit b518c5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions system_tests/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def _assert_likelihood(self, likelihood):
Likelihood.VERY_UNLIKELY]
self.assertIn(likelihood, levels)

def _maybe_http_skip(self, message):
if not Config.CLIENT._use_gax:
def _pb_not_implemented_skip(self, message):
if Config.CLIENT._use_gax:
self.skipTest(message)


Expand Down Expand Up @@ -195,7 +195,6 @@ def _assert_face(self, face):

def test_detect_faces_content(self):
client = Config.CLIENT
self._maybe_http_skip('gRPC is required for face detection.')
with open(FACE_FILE, 'rb') as image_file:
image = client.image(content=image_file.read())
faces = image.detect_faces()
Expand All @@ -204,7 +203,6 @@ def test_detect_faces_content(self):
self._assert_face(face)

def test_detect_faces_gcs(self):
self._maybe_http_skip('gRPC is required for face detection.')
bucket_name = Config.TEST_BUCKET.name
blob_name = 'faces.jpg'
blob = Config.TEST_BUCKET.blob(blob_name)
Expand All @@ -221,7 +219,6 @@ def test_detect_faces_gcs(self):
self._assert_face(face)

def test_detect_faces_filename(self):
self._maybe_http_skip('gRPC is required for face detection.')
client = Config.CLIENT
image = client.image(filename=FACE_FILE)
faces = image.detect_faces()
Expand Down Expand Up @@ -296,7 +293,7 @@ class TestVisionClientLandmark(BaseVisionTestCase):
DESCRIPTIONS = ('Mount Rushmore',)

def setUp(self):
Config.CLIENT = vision.Client(use_gax=True)
Config.CLIENT = vision.Client()
self.to_delete_by_case = []

def tearDown(self):
Expand Down Expand Up @@ -353,7 +350,7 @@ def test_detect_landmark_filename(self):

class TestVisionClientSafeSearch(BaseVisionTestCase):
def setUp(self):
Config.CLIENT = vision.Client(use_gax=False)
Config.CLIENT = vision.Client()
self.to_delete_by_case = []

def tearDown(self):
Expand All @@ -370,7 +367,8 @@ def _assert_safe_search(self, safe_search):
self._assert_likelihood(safe_search.violence)

def test_detect_safe_search_content(self):
self._maybe_http_skip('gRPC is required for safe search detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for safe search detection.')
client = Config.CLIENT
with open(FACE_FILE, 'rb') as image_file:
image = client.image(content=image_file.read())
Expand All @@ -380,7 +378,8 @@ def test_detect_safe_search_content(self):
self._assert_safe_search(safe_search)

def test_detect_safe_search_gcs(self):
self._maybe_http_skip('gRPC is required for safe search detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for safe search detection.')
bucket_name = Config.TEST_BUCKET.name
blob_name = 'faces.jpg'
blob = Config.TEST_BUCKET.blob(blob_name)
Expand All @@ -398,7 +397,8 @@ def test_detect_safe_search_gcs(self):
self._assert_safe_search(safe_search)

def test_detect_safe_search_filename(self):
self._maybe_http_skip('gRPC is required for safe search detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for safe search detection.')
client = Config.CLIENT
image = client.image(filename=FACE_FILE)
safe_searches = image.detect_safe_search()
Expand Down Expand Up @@ -470,7 +470,7 @@ def test_detect_text_filename(self):

class TestVisionClientImageProperties(BaseVisionTestCase):
def setUp(self):
Config.CLIENT = vision.Client(use_gax=False)
Config.CLIENT = vision.Client()
self.to_delete_by_case = []

def tearDown(self):
Expand All @@ -497,7 +497,8 @@ def _assert_properties(self, image_property):
self.assertNotEqual(color_info.score, 0.0)

def test_detect_properties_content(self):
self._maybe_http_skip('gRPC is required for text detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for text detection.')
client = Config.CLIENT
with open(FACE_FILE, 'rb') as image_file:
image = client.image(content=image_file.read())
Expand All @@ -507,7 +508,8 @@ def test_detect_properties_content(self):
self._assert_properties(image_property)

def test_detect_properties_gcs(self):
self._maybe_http_skip('gRPC is required for text detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for text detection.')
client = Config.CLIENT
bucket_name = Config.TEST_BUCKET.name
blob_name = 'faces.jpg'
Expand All @@ -525,7 +527,8 @@ def test_detect_properties_gcs(self):
self._assert_properties(image_property)

def test_detect_properties_filename(self):
self._maybe_http_skip('gRPC is required for text detection.')
self._pb_not_implemented_skip(
'gRPC not implemented for text detection.')
client = Config.CLIENT
image = client.image(filename=FACE_FILE)
properties = image.detect_properties()
Expand Down
2 changes: 1 addition & 1 deletion vision/google/cloud/vision/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Client(JSONClient):
_vision_api_internal = None

def __init__(self, project=None, credentials=None, http=None,
use_gax=False):
use_gax=None):
super(Client, self).__init__(
project=project, credentials=credentials, http=http)
self._connection = Connection(
Expand Down

0 comments on commit b518c5f

Please sign in to comment.