added simple unit tests for pypo.

This commit is contained in:
mkonecny 2010-12-15 16:38:38 -05:00
parent 1b3186af50
commit d7c0f5cc15
4 changed files with 36 additions and 12 deletions

View File

@ -83,10 +83,10 @@ version_url = 'version/api_key/%%api_key%%'
export_url = 'schedule/api_key/%%api_key%%/from/%%from%%/to/%%to%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notifyScheduleGroupPlay/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notifyMediaItemStartPlay/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'

View File

@ -13,33 +13,33 @@ handlers=consoleHandler,fileHandlerERROR,fileHandlerDEBUG
[logger_libs]
handlers=nullHandler
level=DEBUG
level=CRITICAL
qualname="process"
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=DEBUG
level=CRITICAL
formatter=simpleFormatter
args=(sys.stdout,)
[handler_fileHandlerERROR]
class=FileHandler
level=WARNING
level=CRITICAL
formatter=simpleFormatter
args=("./error.log",)
args=("./error-unit-test.log",)
[handler_fileHandlerDEBUG]
class=FileHandler
level=DEBUG
level=CRITICAL
formatter=simpleFormatter
args=("./debug.log",)
args=("./debug-unit-test.log",)
[handler_nullHandler]
class=FileHandler
level=DEBUG
level=CRITICAL
formatter=simpleFormatter
args=("./log_null.log",)
args=("./log-null-unit-test.log",)
[formatter_simpleFormatter]

24
pypo/pypo-api-validator.py Normal file → Executable file
View File

@ -45,6 +45,30 @@ class TestApiFunctions(unittest.TestCase):
def test_is_server_compatible(self):
self.assertTrue(self.api_client.is_server_compatible(False))
def test_get_schedule(self):
status, response = self.api_client.get_schedule()
self.assertTrue(response.has_key("status"))
self.assertTrue(response.has_key("playlists"))
self.assertTrue(response.has_key("check"))
self.assertTrue(status == 1)
def test_get_media(self):
self.assertTrue(True)
def test_notify_scheduled_item_start_playing(self):
arr = dict()
arr["x"] = dict()
arr["x"]["schedule_id"]=1
response = self.api_client.notify_scheduled_item_start_playing("x", arr)
self.assertTrue(response.has_key("status"))
self.assertTrue(response.has_key("message"))
def test_notify_media_item_start_playing(self):
response = self.api_client.notify_media_item_start_playing('{"schedule_id":1}', 5)
self.assertTrue(response.has_key("status"))
self.assertTrue(response.has_key("message"))
if __name__ == '__main__':
unittest.main()

View File

@ -214,7 +214,7 @@ class Playout:
def get_schedule(self):
logger = logging.getLogger()
status, response = self.api_client.get_schedule();
status, response = self.api_client.get_schedule()
if status == 1:
logger.info("dump serialized schedule to %s", self.schedule_file)
@ -498,7 +498,7 @@ class Playout:
logger.error("%s", e)
# cue
print "STARTIONG CUE"
print "STARTING CUE"
print self.cue_file.cue(dst_tmp, dst, float(media['cue_in']) / 1000, float(media['cue_out']) / 1000)
print "END CUE"