Skip to content

Commit

Permalink
Adds checks for all features using https. (#944)
Browse files Browse the repository at this point in the history
* Adds checks for all features using https.

* Fixes overindent for lint
  • Loading branch information
gguuss authored and dpebot committed May 15, 2017
1 parent 1750119 commit a6df5b2
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions vision/cloud-client/detect/detect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__),
Expand All @@ -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__),
Expand All @@ -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__),
Expand All @@ -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__),
Expand All @@ -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__),
Expand All @@ -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__),
Expand All @@ -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(
Expand All @@ -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__),
Expand All @@ -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__),
Expand All @@ -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

0 comments on commit a6df5b2

Please sign in to comment.