Skip to content

Commit

Permalink
added skip check for playback server
Browse files Browse the repository at this point in the history
  • Loading branch information
seanshahkarami committed Aug 14, 2023
1 parent 4add803 commit c79a423
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pathlib import Path
import os.path
from itertools import product
import subprocess


def generate_audio_data(samplerate, channels, dtype):
Expand Down Expand Up @@ -125,13 +126,23 @@ def test_get_timestamp(self):
ts = get_timestamp()
self.assertIsInstance(ts, int)

def test_camera_file_snapshot(self):

def playback_server_available():
try:
output = subprocess.check_output(["docker-compose", "logs", "playback-server"])
except subprocess.CalledProcessError:
return False
return b"Serving data" in output


class TestCamera(unittest.TestCase):
def test_file_snapshot(self):
# open test.mp4 is a test video 90 480x640 frames
cam = Camera("file://tests/test.mp4")
sample = cam.snapshot()
assert sample.data.shape == (640, 480, 3)

def test_camera_file_stream(self):
def test_file_stream(self):
# open test.mp4 is a test video 90 480x640 frames
cam = Camera("file://tests/test.mp4")
numframes = 0
Expand All @@ -140,13 +151,15 @@ def test_camera_file_stream(self):
numframes += 1
assert numframes == 90

def test_camera_stream_snapshot(self):
@unittest.skipUnless(playback_server_available(), "playback server not available")
def test_stream_snapshot(self):
# open playback server which provides test video stream of 800x600 frames
cam = Camera("http://127.0.0.1:8090/bottom/live.mp4")
sample = cam.snapshot()
assert sample.data.shape == (600, 800, 3)

def test_camera_stream_stream(self):
@unittest.skipUnless(playback_server_available(), "playback server not available")
def test_stream_stream(self):
# open playback server which provides test video stream of 800x600 frames
cam = Camera("http://127.0.0.1:8090/bottom/live.mp4")
numframes = 0
Expand Down

0 comments on commit c79a423

Please sign in to comment.