13
13
# limitations under the License.
14
14
15
15
import os
16
+ import uuid
16
17
17
18
from google .cloud import storage
18
19
21
22
ASSET_BUCKET = "cloud-samples-data"
22
23
23
24
BUCKET = os .environ ['CLOUD_STORAGE_BUCKET' ]
24
- OUTPUT_PREFIX = 'OCR_PDF_TEST_OUTPUT'
25
+ OUTPUT_PREFIX = 'TEST_OUTPUT_{}' . format ( uuid . uuid4 ())
25
26
GCS_SOURCE_URI = 'gs://{}/HodgeConj.pdf' .format (BUCKET )
26
27
GCS_DESTINATION_URI = 'gs://{}/{}/' .format (BUCKET , OUTPUT_PREFIX )
27
28
@@ -42,14 +43,6 @@ def test_labels_uri(capsys):
42
43
assert 'Labels' in out
43
44
44
45
45
- def test_labels_http (capsys ):
46
- uri = 'https://storage-download.googleapis.com/{}' \
47
- '/vision/label/wakeupcat.jpg'
48
- detect .detect_labels_uri (uri .format (ASSET_BUCKET ))
49
- out , _ = capsys .readouterr ()
50
- assert 'Labels' in out
51
-
52
-
53
46
def test_landmarks (capsys ):
54
47
file_name = os .path .join (
55
48
os .path .dirname (__file__ ),
@@ -66,13 +59,6 @@ def test_landmarks_uri(capsys):
66
59
assert 'palace' in out .lower ()
67
60
68
61
69
- def test_landmarks_http (capsys ):
70
- uri = 'https://storage-download.googleapis.com/{}/vision/landmark/pofa.jpg'
71
- detect .detect_landmarks_uri (uri .format (ASSET_BUCKET ))
72
- out , _ = capsys .readouterr ()
73
- assert 'palace' in out .lower ()
74
-
75
-
76
62
def test_faces (capsys ):
77
63
file_name = os .path .join (
78
64
os .path .dirname (__file__ ),
@@ -89,14 +75,6 @@ def test_faces_uri(capsys):
89
75
assert 'POSSIBLE' in out
90
76
91
77
92
- def test_faces_http (capsys ):
93
- uri = ('https://storage-download.googleapis.com/{}/vision/' +
94
- 'face/face_no_surprise.jpg' )
95
- detect .detect_faces_uri (uri .format (ASSET_BUCKET ))
96
- out , _ = capsys .readouterr ()
97
- assert 'POSSIBLE' in out
98
-
99
-
100
78
def test_logos (capsys ):
101
79
file_name = os .path .join (
102
80
os .path .dirname (__file__ ),
@@ -113,14 +91,6 @@ def test_logos_uri(capsys):
113
91
assert 'google' in out .lower ()
114
92
115
93
116
- def test_logos_http (capsys ):
117
- uri = 'https://storage-download.googleapis.com/{}' \
118
- '/vision/logo/logo_google.png'
119
- detect .detect_logos_uri (uri .format (ASSET_BUCKET ))
120
- out , _ = capsys .readouterr ()
121
- assert 'google' in out .lower ()
122
-
123
-
124
94
def test_safe_search (capsys ):
125
95
file_name = os .path .join (
126
96
os .path .dirname (__file__ ),
@@ -139,15 +109,6 @@ def test_safe_search_uri(capsys):
139
109
assert 'racy: ' in out
140
110
141
111
142
- def test_safe_search_http (capsys ):
143
- uri = 'https://storage-download.googleapis.com/{}' \
144
- '/vision/label/wakeupcat.jpg'
145
- detect .detect_safe_search_uri (uri .format (ASSET_BUCKET ))
146
- out , _ = capsys .readouterr ()
147
- assert 'VERY_LIKELY' in out
148
- assert 'racy: ' in out
149
-
150
-
151
112
def test_detect_text (capsys ):
152
113
file_name = os .path .join (
153
114
os .path .dirname (__file__ ),
@@ -164,13 +125,6 @@ def test_detect_text_uri(capsys):
164
125
assert '37%' in out
165
126
166
127
167
- def test_detect_text_http (capsys ):
168
- uri = 'https://storage-download.googleapis.com/{}/vision/text/screen.jpg'
169
- detect .detect_text_uri (uri .format (ASSET_BUCKET ))
170
- out , _ = capsys .readouterr ()
171
- assert '37%' in out
172
-
173
-
174
128
def test_detect_properties (capsys ):
175
129
file_name = os .path .join (
176
130
os .path .dirname (__file__ ),
@@ -187,13 +141,6 @@ def test_detect_properties_uri(capsys):
187
141
assert 'frac' in out
188
142
189
143
190
- def test_detect_properties_http (capsys ):
191
- uri = 'https://storage-download.googleapis.com/{}/vision/landmark/pofa.jpg'
192
- detect .detect_properties_uri (uri .format (ASSET_BUCKET ))
193
- out , _ = capsys .readouterr ()
194
- assert 'frac' in out
195
-
196
-
197
144
# Vision 1.1 tests
198
145
def test_detect_web (capsys ):
199
146
file_name = os .path .join (
@@ -211,13 +158,6 @@ def test_detect_web_uri(capsys):
211
158
assert 'best guess label: palace of fine arts' in out .lower ()
212
159
213
160
214
- def test_detect_web_http (capsys ):
215
- uri = 'https://storage-download.googleapis.com/{}/vision/landmark/pofa.jpg'
216
- detect .detect_web_uri (uri .format (ASSET_BUCKET ))
217
- out , _ = capsys .readouterr ()
218
- assert 'best guess label: palace of fine arts' in out .lower ()
219
-
220
-
221
161
def test_detect_web_with_geo (capsys ):
222
162
file_name = os .path .join (
223
163
os .path .dirname (__file__ ),
@@ -254,13 +194,6 @@ def test_detect_document_uri(capsys):
254
194
assert 'class' in out
255
195
256
196
257
- def test_detect_document_http (capsys ):
258
- uri = 'https://storage-download.googleapis.com/{}/vision/text/screen.jpg'
259
- detect .detect_document_uri (uri .format (ASSET_BUCKET ))
260
- out , _ = capsys .readouterr ()
261
- assert 'class' in out
262
-
263
-
264
197
def test_detect_crop_hints (capsys ):
265
198
file_name = os .path .join (
266
199
os .path .dirname (__file__ ),
@@ -277,14 +210,6 @@ def test_detect_crop_hints_uri(capsys):
277
210
assert 'bounds: ' in out
278
211
279
212
280
- def test_detect_crop_hints_http (capsys ):
281
- uri = 'https://storage-download.googleapis.com/{}' \
282
- '/vision/label/wakeupcat.jpg'
283
- detect .detect_crop_hints_uri (uri .format (ASSET_BUCKET ))
284
- out , _ = capsys .readouterr ()
285
- assert 'bounds: ' in out
286
-
287
-
288
213
def test_async_detect_document (capsys ):
289
214
storage_client = storage .Client ()
290
215
bucket = storage_client .get_bucket (BUCKET )
0 commit comments