Skip to content

Commit

Permalink
Chnaged structure of testsource
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Aug 7, 2013
1 parent c64a768 commit 768a2e6
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 131 deletions.
3 changes: 1 addition & 2 deletions python-api/gstswitch/helpers.py
Expand Up @@ -40,8 +40,7 @@ def new_test_video(self,
pattern,
timeoverlay,
clockoverlay)
if testsrc is None:
pass
testsrc.run()
self.running_tests.append(testsrc)

def get_test_video(self):
Expand Down
243 changes: 123 additions & 120 deletions python-api/gstswitch/test_testsource.py
Expand Up @@ -6,146 +6,149 @@

class TestVideoSrcPort(object):

def test_blank(self):
tests = ['', None, [], {}]
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=test)

def test_range(self):
tests = [-100, 1e7, 65536]
for test in tests:
with pytest.raises(RangeError):
VideoSrc(port=test)

def test_invalid(self):
tests = [[1, 2, 3, 4], {1: 2, 2: 3}, '1e10']
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=test)

def test_normal(self):
tests = [1, 65535, 1000]
for test in tests:
src = VideoSrc(port=test)
assert src.port == test
def test_blank(self):
tests = ['', None, [], {}]
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=test)

def test_range(self):
tests = [-100, 1e7, 65536]
for test in tests:
with pytest.raises(RangeError):
VideoSrc(port=test)

def test_invalid(self):
tests = [[1, 2, 3, 4], {1: 2, 2: 3}, '1e10']
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=test)

def test_normal(self):
tests = [1, 65535, 1000]
for test in tests:
src = VideoSrc(port=test)
assert src.port == test

class TestVideoSrcWidth(object):

def test_blank(self):
tests = ['', None, [], {}]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, width=test)

def test_non_positive(self):
tests = ['-1.111', -1.111, 0, -1e10]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, width=test)

def test_invalid(self):
tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, width=test)

def test_normal(self):
tests = [ 1e6, 300, '200']
port = 1000
for test in tests:
src = VideoSrc(port=port, width=test)
assert src.width == test
def test_blank(self):
tests = ['', None, [], {}]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, width=test)

def test_non_positive(self):
tests = ['-1.111', -1.111, 0, -1e10]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, width=test)

def test_invalid(self):
tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, width=test)

def test_normal(self):
tests = [ 1e6, 300, '200']
port = 1000
for test in tests:
src = VideoSrc(port=port, width=test)
assert src.width == test


class TestVideoSrcHeight(object):

def test_blank(self):
tests = ['', None, [], {}]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, height=test)

def test_non_positive(self):
tests = ['-1.111', -1.111, 0, -1e10]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, height=test)

def test_invalid(self):
tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, height=test)

def test_normal(self):
tests = [1e6, 300, '200']
port = 1000
for test in tests:
src = VideoSrc(port=port, height=test)
assert src.height == test
def test_blank(self):
tests = ['', None, [], {}]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, height=test)

def test_non_positive(self):
tests = ['-1.111', -1.111, 0, -1e10]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, height=test)

def test_invalid(self):
tests = [[1, 2, 3], {1: 2, 2: 3}, (1, 2)]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, height=test)

def test_normal(self):
tests = [1e6, 300, '200']
port = 1000
for test in tests:
src = VideoSrc(port=port, height=test)
assert src.height == test


class TestVideoSrcPattern(object):

def test_range(self):
tests = [-100, 1e7, 65536, -1, 20]
port = 1000
for test in tests:
with pytest.raises(RangeError):
VideoSrc(port=port, pattern=test)
def test_range(self):
tests = [-100, 1e7, 65536, -1, 20]
port = 1000
for test in tests:
with pytest.raises(RangeError):
VideoSrc(port=port, pattern=test)

def test_invalid(self):
tests = [[1, 2, 3, 4], {1: 2, 2: 3}]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, pattern=test)
def test_invalid(self):
tests = [[1, 2, 3, 4], {1: 2, 2: 3}]
port = 1000
for test in tests:
with pytest.raises(TypeError):
VideoSrc(port=port, pattern=test)

def test_normal(self):
tests = [1, 0, 19, 10]
port = 1000
for test in tests:
src = VideoSrc(port=port, pattern=test)
assert src.pattern == str(test)
def test_normal(self):
tests = [1, 0, 19, 10]
port = 1000
for test in tests:
src = VideoSrc(port=port, pattern=test)
assert src.pattern == str(test)


class TestVideoSrcTimeOverlay(object):

def test_fail(self):
tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, timeoverlay=test)
def test_fail(self):
tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, timeoverlay=test)

def test_normal(self):
tests = [True, False]
port = 1000
for test in tests:
src = VideoSrc(port=port, timeoverlay=test)
assert src.timeoverlay == test
def test_normal(self):
tests = [True, False]
port = 1000
for test in tests:
src = VideoSrc(port=port, timeoverlay=test)
assert src.timeoverlay == test



class TestVideoSrcClockOverlay(object):

def test_fail(self):
tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, clockoverlay=test)

def test_normal(self):
tests = [True, False]
port = 1000
for test in tests:
src = VideoSrc(port=port, clockoverlay=test)
assert src.clockoverlay == test
def test_fail(self):
tests = ['', 1234, 'hi', [1, 2], {1: 2}, None, 0, []]
port = 1000
for test in tests:
with pytest.raises(ValueError):
VideoSrc(port=port, clockoverlay=test)

def test_normal(self):
tests = [True, False]
port = 1000
for test in tests:
src = VideoSrc(port=port, clockoverlay=test)
assert src.clockoverlay == test


# class TestVideoSrc
19 changes: 10 additions & 9 deletions python-api/gstswitch/testsource.py
Expand Up @@ -230,6 +230,7 @@ class VideoSrc(object):
:param timeoverlay: True to enable a running time over video
:param clockoverlay: True to enable current clock time over video
"""
HOST = '127.0.0.1'

def __init__(
self,
Expand All @@ -247,15 +248,6 @@ def __init__(
self.timeoverlay = timeoverlay
self.clockoverlay = clockoverlay

self.pipeline = VideoPipeline(
self.port,
self.width,
self.height,
self.pattern,
self.timeoverlay,
self.clockoverlay)
self.run()

@property
def port(self):
return self._port
Expand Down Expand Up @@ -359,6 +351,15 @@ def clockoverlay(self, clockoverlay):

def run(self):
"""Run the pipeline"""
self.pipeline = VideoPipeline(
self.port,
self.HOST,
self.width,
self.height,
self.pattern,
self.timeoverlay,
self.clockoverlay)

self.pipeline.play()

def pause(self):
Expand Down

0 comments on commit 768a2e6

Please sign in to comment.