1313# limitations under the License.
1414
1515import os
16+ import uuid
1617
1718from google .cloud import storage
1819
2122ASSET_BUCKET = "cloud-samples-data"
2223
2324BUCKET = os .environ ['CLOUD_STORAGE_BUCKET' ]
24- OUTPUT_PREFIX = 'OCR_PDF_TEST_OUTPUT'
25+ OUTPUT_PREFIX = 'TEST_OUTPUT_{}' . format ( uuid . uuid4 ())
2526GCS_SOURCE_URI = 'gs://{}/HodgeConj.pdf' .format (BUCKET )
2627GCS_DESTINATION_URI = 'gs://{}/{}/' .format (BUCKET , OUTPUT_PREFIX )
2728
@@ -42,14 +43,6 @@ def test_labels_uri(capsys):
4243 assert 'Labels' in out
4344
4445
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-
5346def test_landmarks (capsys ):
5447 file_name = os .path .join (
5548 os .path .dirname (__file__ ),
@@ -66,13 +59,6 @@ def test_landmarks_uri(capsys):
6659 assert 'palace' in out .lower ()
6760
6861
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-
7662def test_faces (capsys ):
7763 file_name = os .path .join (
7864 os .path .dirname (__file__ ),
@@ -89,14 +75,6 @@ def test_faces_uri(capsys):
8975 assert 'POSSIBLE' in out
9076
9177
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-
10078def test_logos (capsys ):
10179 file_name = os .path .join (
10280 os .path .dirname (__file__ ),
@@ -113,14 +91,6 @@ def test_logos_uri(capsys):
11391 assert 'google' in out .lower ()
11492
11593
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-
12494def test_safe_search (capsys ):
12595 file_name = os .path .join (
12696 os .path .dirname (__file__ ),
@@ -139,15 +109,6 @@ def test_safe_search_uri(capsys):
139109 assert 'racy: ' in out
140110
141111
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-
151112def test_detect_text (capsys ):
152113 file_name = os .path .join (
153114 os .path .dirname (__file__ ),
@@ -164,13 +125,6 @@ def test_detect_text_uri(capsys):
164125 assert '37%' in out
165126
166127
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-
174128def test_detect_properties (capsys ):
175129 file_name = os .path .join (
176130 os .path .dirname (__file__ ),
@@ -187,13 +141,6 @@ def test_detect_properties_uri(capsys):
187141 assert 'frac' in out
188142
189143
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-
197144# Vision 1.1 tests
198145def test_detect_web (capsys ):
199146 file_name = os .path .join (
@@ -211,13 +158,6 @@ def test_detect_web_uri(capsys):
211158 assert 'best guess label: palace of fine arts' in out .lower ()
212159
213160
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-
221161def test_detect_web_with_geo (capsys ):
222162 file_name = os .path .join (
223163 os .path .dirname (__file__ ),
@@ -254,13 +194,6 @@ def test_detect_document_uri(capsys):
254194 assert 'class' in out
255195
256196
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-
264197def test_detect_crop_hints (capsys ):
265198 file_name = os .path .join (
266199 os .path .dirname (__file__ ),
@@ -277,14 +210,6 @@ def test_detect_crop_hints_uri(capsys):
277210 assert 'bounds: ' in out
278211
279212
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-
288213def test_async_detect_document (capsys ):
289214 storage_client = storage .Client ()
290215 bucket = storage_client .get_bucket (BUCKET )
0 commit comments