Skip to content

Commit 09c145c

Browse files
nnegreyTakashi Matsuo
authored andcommitted
video: fix flaky beta tests [(#3235)](GoogleCloudPlatform/python-docs-samples#3235)
* video: fix flaky beta tests * fix failing test with new video file * add local file tests * update test Co-authored-by: Takashi Matsuo <[email protected]>
1 parent ef07579 commit 09c145c

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

packages/google-cloud-videointelligence/samples/analyze/analyze_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def test_analyze_labels(capsys):
4848
assert "label description: cat" in out
4949

5050

51+
@pytest.mark.slow
52+
def test_analyze_labels_file(capsys):
53+
analyze.analyze_labels_file("resources/googlework_tiny.mp4")
54+
out, _ = capsys.readouterr()
55+
assert "label description" in out
56+
57+
5158
@pytest.mark.slow
5259
def test_analyze_explicit_content(capsys):
5360
analyze.analyze_explicit_content("gs://cloud-samples-data/video/cat.mp4")
@@ -75,8 +82,23 @@ def test_detect_text_gcs(capsys):
7582
assert text_exists
7683

7784

85+
@pytest.mark.slow
86+
def test_detect_text(capsys):
87+
analyze.video_detect_text("resources/googlework_tiny.mp4")
88+
out, _ = capsys.readouterr()
89+
assert 'Text' in out
90+
91+
7892
@pytest.mark.slow
7993
def test_track_objects_gcs(capsys):
8094
analyze.track_objects_gcs("gs://cloud-samples-data/video/cat.mp4")
8195
out, _ = capsys.readouterr()
8296
assert "cat" in out
97+
98+
99+
@pytest.mark.slow
100+
def test_track_objects(capsys):
101+
in_file = "./resources/googlework_tiny.mp4"
102+
analyze.track_objects(in_file)
103+
out, _ = capsys.readouterr()
104+
assert "Entity id" in out

packages/google-cloud-videointelligence/samples/analyze/beta_snippets_test.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,11 @@ def test_detect_text_gcs():
152152

153153

154154
@pytest.mark.slow
155-
def test_track_objects():
156-
in_file = "./resources/cat.mp4"
157-
object_annotations = beta_snippets.track_objects(in_file)
158-
159-
text_exists = False
160-
for object_annotation in object_annotations:
161-
if "CAT" in object_annotation.entity.description.upper():
162-
text_exists = True
163-
assert text_exists
164-
assert object_annotations[0].frames[0].normalized_bounding_box.left >= 0.0
165-
assert object_annotations[0].frames[0].normalized_bounding_box.left <= 1.0
155+
def test_track_objects(capsys):
156+
in_file = "./resources/googlework_tiny.mp4"
157+
beta_snippets.track_objects(in_file)
158+
out, _ = capsys.readouterr()
159+
assert "Entity id" in out
166160

167161

168162
@pytest.mark.slow

packages/google-cloud-videointelligence/samples/analyze/video_detect_logo_beta_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_sample_annotate_video(capsys):
2626

2727
out, _ = capsys.readouterr()
2828

29-
assert "Description : Google Maps" in out
29+
assert "Description" in out
3030
assert "Confidence" in out
3131
assert "Start Time Offset" in out
3232
assert "End Time Offset" in out

packages/google-cloud-videointelligence/samples/analyze/video_detect_logo_gcs_beta_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_sample_annotate_video(capsys):
2626

2727
out, _ = capsys.readouterr()
2828

29-
assert "Description : Google Maps" in out
29+
assert "Description" in out
3030
assert "Confidence" in out
3131
assert "Start Time Offset" in out
3232
assert "End Time Offset" in out

0 commit comments

Comments
 (0)