Skip to content

Commit a6df5b2

Browse files
gguussdpebot
authored andcommitted
Adds checks for all features using https. (#944)
* Adds checks for all features using https. * Fixes overindent for lint
1 parent 1750119 commit a6df5b2

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

vision/cloud-client/detect/detect_test.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def test_labels_uri(capsys):
3535
assert 'Labels' in out
3636

3737

38+
def test_labels_http(capsys):
39+
uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg'
40+
detect.detect_labels_uri(uri.format(BUCKET))
41+
out, _ = capsys.readouterr()
42+
assert 'Labels' in out
43+
44+
3845
def test_landmarks(capsys):
3946
file_name = os.path.join(
4047
os.path.dirname(__file__),
@@ -51,6 +58,13 @@ def test_landmarks_uri(capsys):
5158
assert 'Palace' in out
5259

5360

61+
def test_landmarks_http(capsys):
62+
uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg'
63+
detect.detect_landmarks_uri(uri.format(BUCKET))
64+
out, _ = capsys.readouterr()
65+
assert 'Palace' in out
66+
67+
5468
def test_faces(capsys):
5569
file_name = os.path.join(
5670
os.path.dirname(__file__),
@@ -67,6 +81,14 @@ def test_faces_uri(capsys):
6781
assert 'Likelihood.POSSIBLE' in out
6882

6983

84+
def test_faces_http(capsys):
85+
uri = ('https://storage-download.googleapis.com/{}/vision/' +
86+
'face_no_surprise.jpg')
87+
detect.detect_faces_uri(uri.format(BUCKET))
88+
out, _ = capsys.readouterr()
89+
assert 'Likelihood.POSSIBLE' in out
90+
91+
7092
def test_logos(capsys):
7193
file_name = os.path.join(
7294
os.path.dirname(__file__),
@@ -83,6 +105,13 @@ def test_logos_uri(capsys):
83105
assert 'Google' in out
84106

85107

108+
def test_logos_http(capsys):
109+
uri = 'https://storage-download.googleapis.com/{}/vision/logos.png'
110+
detect.detect_logos_uri(uri.format(BUCKET))
111+
out, _ = capsys.readouterr()
112+
assert 'Google' in out
113+
114+
86115
def test_safe_search(capsys):
87116
file_name = os.path.join(
88117
os.path.dirname(__file__),
@@ -99,6 +128,13 @@ def test_safe_search_uri(capsys):
99128
assert 'Likelihood.VERY_LIKELY' in out
100129

101130

131+
def test_safe_search_http(capsys):
132+
uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg'
133+
detect.detect_safe_search_uri(uri.format(BUCKET))
134+
out, _ = capsys.readouterr()
135+
assert 'Likelihood.VERY_LIKELY' in out
136+
137+
102138
def test_detect_text(capsys):
103139
file_name = os.path.join(
104140
os.path.dirname(__file__),
@@ -115,6 +151,13 @@ def test_detect_text_uri(capsys):
115151
assert '37%' in out
116152

117153

154+
def test_detect_text_http(capsys):
155+
uri = 'https://storage-download.googleapis.com/{}/vision/text.jpg'
156+
detect.detect_text_uri(uri.format(BUCKET))
157+
out, _ = capsys.readouterr()
158+
assert '37%' in out
159+
160+
118161
def test_detect_properties(capsys):
119162
file_name = os.path.join(
120163
os.path.dirname(__file__),
@@ -131,6 +174,13 @@ def test_detect_properties_uri(capsys):
131174
assert 'frac' in out
132175

133176

177+
def test_detect_properties_http(capsys):
178+
uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg'
179+
detect.detect_properties_uri(uri.format(BUCKET))
180+
out, _ = capsys.readouterr()
181+
assert 'frac' in out
182+
183+
134184
# Vision 1.1 tests
135185
def test_detect_web(capsys):
136186
file_name = os.path.join(
@@ -148,6 +198,13 @@ def test_detect_web_uri(capsys):
148198
assert 'Description: Palace of Fine Arts Theatre' in out
149199

150200

201+
def test_detect_web_http(capsys):
202+
uri = 'https://storage-download.googleapis.com/{}/vision/landmark.jpg'
203+
detect.detect_web_uri(uri.format(BUCKET))
204+
out, _ = capsys.readouterr()
205+
assert 'Description: Palace of Fine Arts Theatre' in out
206+
207+
151208
def test_detect_document(capsys):
152209
file_name = os.path.join(
153210
os.path.dirname(__file__),
@@ -164,6 +221,13 @@ def test_detect_document_uri(capsys):
164221
assert '37%' in out
165222

166223

224+
def test_detect_document_http(capsys):
225+
uri = 'https://storage-download.googleapis.com/{}/vision/text.jpg'
226+
detect.detect_document_uri(uri.format(BUCKET))
227+
out, _ = capsys.readouterr()
228+
assert '37%' in out
229+
230+
167231
def test_detect_crop_hints(capsys):
168232
file_name = os.path.join(
169233
os.path.dirname(__file__),
@@ -178,3 +242,10 @@ def test_detect_crop_hints_uri(capsys):
178242
detect.detect_crop_hints_uri(file_name)
179243
out, _ = capsys.readouterr()
180244
assert 'bounds: (0,0)' in out
245+
246+
247+
def test_detect_crop_hints_http(capsys):
248+
uri = 'https://storage-download.googleapis.com/{}/vision/wakeupcat.jpg'
249+
detect.detect_crop_hints_uri(uri.format(BUCKET))
250+
out, _ = capsys.readouterr()
251+
assert 'bounds: (0,0)' in out

0 commit comments

Comments
 (0)