Skip to content

Commit

Permalink
Fix record file format for API
Browse files Browse the repository at this point in the history
  • Loading branch information
hyades committed Jan 10, 2015
1 parent d9c5cf7 commit e8e90bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion python-api/gstswitch/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
video_port=3000,
audio_port=4000,
control_port=5000,
record_file='record.data'):
record_file='record-%Y-%m-%d_%H%M%S.data'):

super(Server, self).__init__()

Expand Down
12 changes: 4 additions & 8 deletions python-api/tests/integrationtests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def new_record(self):
def test_new_record(self):
"""Test new_record"""
for _ in range(self.NUM):
serv = Server(path=PATH, record_file="test.data")
serv = Server(path=PATH, record_file="test-%Y.data")
try:
serv.run()

Expand All @@ -375,18 +375,14 @@ def test_new_record(self):
sources.new_test_video()

curr_time = datetime.datetime.now()
alt_curr_time = curr_time + datetime.timedelta(0, 1)
time_str = curr_time.strftime('%Y-%m-%d %H%M%S')
alt_time_str = alt_curr_time.strftime('%Y-%m-%d %H%M%S')
test_filename = "test {0}.data".format(time_str)
alt_test_filename = "test {0}.data".format(alt_time_str)
time_str = curr_time.strftime('%Y')
test_filename = "test-{0}.data".format(time_str)

res = self.new_record()
print res
sources.terminate_video()
serv.terminate(1)
assert ((os.path.exists(test_filename)) or
(os.path.exists(alt_test_filename))) is True
assert os.path.exists(test_filename) is True
finally:
if serv.proc:
poll = serv.proc.poll()
Expand Down
6 changes: 3 additions & 3 deletions python-api/tests/unittests/test_server_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process().split() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 --record=record.data".split()
--control-port=5000 --record=record-%Y-%m-%d_%H%M%S.data".split()

def test_path_provided_no_slash(self):
"""Test if a path is provided"""
Expand All @@ -41,7 +41,7 @@ def mock_method(arg):
serv._start_process = mock_method
assert serv._run_process().split() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 --record=record.data".split()
--control-port=5000 --record=record-%Y-%m-%d_%H%M%S.data".split()

def test_path_empty(self, monkeypatch):
"""Test if null path is given"""
Expand All @@ -60,7 +60,7 @@ def mockreturn(path):
serv._start_process = mock_method
assert serv._run_process().split() == "/usr/gst-switch-srv \
--video-input-port=3000 --audio-input-port=4000 \
--control-port=5000 --record=record.data".split()
--control-port=5000 --record=record-%Y-%m-%d_%H%M%S.data".split()


class TestVideoPort(object):
Expand Down

0 comments on commit e8e90bc

Please sign in to comment.