Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds checks for all features using https. #944

Merged
merged 2 commits into from
May 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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