From 4c1a6e0241e14fca3ebac7efea197c3afd0021ee Mon Sep 17 00:00:00 2001 From: Gus Class Date: Sat, 13 May 2017 12:46:16 -0700 Subject: [PATCH 1/2] Adds checks for all features using https. --- vision/cloud-client/detect/detect_test.py | 71 +++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/vision/cloud-client/detect/detect_test.py b/vision/cloud-client/detect/detect_test.py index 8dd40b8b2642..6e676df907f9 100644 --- a/vision/cloud-client/detect/detect_test.py +++ b/vision/cloud-client/detect/detect_test.py @@ -35,6 +35,13 @@ def test_labels_uri(capsys): assert 'Labels' in out +def test_labels_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg' + detect.detect_labels_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Labels' in out + + def test_landmarks(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -51,6 +58,13 @@ def test_landmarks_uri(capsys): assert 'Palace' in out +def test_landmarks_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg' + detect.detect_landmarks_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Palace' in out + + def test_faces(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -67,6 +81,14 @@ def test_faces_uri(capsys): assert 'Likelihood.POSSIBLE' in out +def test_faces_http(capsys): + uri = ('https://storage-download.googleapis.com/{}/vision/' + + 'face_no_surprise.jpg') + detect.detect_faces_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Likelihood.POSSIBLE' in out + + def test_logos(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -83,6 +105,13 @@ def test_logos_uri(capsys): assert 'Google' in out +def test_logos_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/logos.png' + detect.detect_logos_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Google' in out + + def test_safe_search(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -99,6 +128,13 @@ def test_safe_search_uri(capsys): assert 'Likelihood.VERY_LIKELY' in out +def test_safe_search_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg' + detect.detect_safe_search_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Likelihood.VERY_LIKELY' in out + + def test_detect_text(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -115,6 +151,13 @@ def test_detect_text_uri(capsys): assert '37%' in out +def test_detect_text_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/text.jpg' + detect.detect_text_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert '37%' in out + + def test_detect_properties(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -131,6 +174,13 @@ def test_detect_properties_uri(capsys): assert 'frac' in out +def test_detect_properties_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg' + detect.detect_properties_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'frac' in out + + # Vision 1.1 tests def test_detect_web(capsys): file_name = os.path.join( @@ -148,6 +198,13 @@ def test_detect_web_uri(capsys): assert 'Description: Palace of Fine Arts Theatre' in out +def test_detect_web_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg' + detect.detect_web_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'Description: Palace of Fine Arts Theatre' in out + + def test_detect_document(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -164,6 +221,13 @@ def test_detect_document_uri(capsys): assert '37%' in out +def test_detect_document_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/text.jpg' + detect.detect_document_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert '37%' in out + + def test_detect_crop_hints(capsys): file_name = os.path.join( os.path.dirname(__file__), @@ -178,3 +242,10 @@ def test_detect_crop_hints_uri(capsys): detect.detect_crop_hints_uri(file_name) out, _ = capsys.readouterr() assert 'bounds: (0,0)' in out + + +def test_detect_crop_hints_http(capsys): + uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg' + detect.detect_crop_hints_uri(uri.format(BUCKET)) + out, _ = capsys.readouterr() + assert 'bounds: (0,0)' in out From 967a3da1d748938ed557fd7e5cbf5ac4c5c07d5d Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 15 May 2017 11:09:19 -0700 Subject: [PATCH 2/2] Fixes overindent for lint --- vision/cloud-client/detect/detect_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vision/cloud-client/detect/detect_test.py b/vision/cloud-client/detect/detect_test.py index 6e676df907f9..ac19579546fd 100644 --- a/vision/cloud-client/detect/detect_test.py +++ b/vision/cloud-client/detect/detect_test.py @@ -83,7 +83,7 @@ def test_faces_uri(capsys): def test_faces_http(capsys): uri = ('https://storage-download.googleapis.com/{}/vision/' + - 'face_no_surprise.jpg') + 'face_no_surprise.jpg') detect.detect_faces_uri(uri.format(BUCKET)) out, _ = capsys.readouterr() assert 'Likelihood.POSSIBLE' in out