From edd7351b76685bb769f157a192b167b29e0ad6c0 Mon Sep 17 00:00:00 2001 From: "paul.baranowski" Date: Wed, 15 Dec 2010 14:25:42 -0500 Subject: [PATCH 1/2] Removed the API directory, all of it has been moved to application/controllers/ApiController.php --- api/api_version.php | 13 -------- api/get_media.php | 47 ---------------------------- api/notify_media_item_start_play.php | 37 ---------------------- api/notify_schedule_group_play.php | 35 --------------------- api/schedule.php | 18 ----------- 5 files changed, 150 deletions(-) delete mode 100644 api/api_version.php delete mode 100644 api/get_media.php delete mode 100644 api/notify_media_item_start_play.php delete mode 100644 api/notify_schedule_group_play.php delete mode 100644 api/schedule.php diff --git a/api/api_version.php b/api/api_version.php deleted file mode 100644 index 350f477d9..000000000 --- a/api/api_version.php +++ /dev/null @@ -1,13 +0,0 @@ -CAMPCASTER_VERSION)); -?> \ No newline at end of file diff --git a/api/get_media.php b/api/get_media.php deleted file mode 100644 index 0ae512bbc..000000000 --- a/api/get_media.php +++ /dev/null @@ -1,47 +0,0 @@ -getRealFilePath(); - if(!is_file($filepath)) - { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - //print 'Ressource in database, but not in storage. Sorry.'; - exit; - } - - // !! binary mode !! - $fp = fopen($filepath, 'rb'); - - header("Content-Type: audio/mpeg"); - header("Content-Length: " . filesize($filepath)); - - fpassthru($fp); - } - else { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - exit; - } -} else { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - exit; -} -exit; - -?> \ No newline at end of file diff --git a/api/notify_media_item_start_play.php b/api/notify_media_item_start_play.php deleted file mode 100644 index 6a415fbff..000000000 --- a/api/notify_media_item_start_play.php +++ /dev/null @@ -1,37 +0,0 @@ -exists()) { - $result = $sg->notifyMediaItemStartPlay($f->getId()); - if (!PEAR::isError($result)) { - echo json_encode(array("status"=>1, "message"=>"")); - exit; - } else { - echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage())); - exit; - } - } else { - echo json_encode(array("status"=>0, "message"=>"Schedule group does not exist: ".$schedule_group_id)); - exit; - } -} else { - echo json_encode(array("status"=>0, "message" => "Incorrect or non-numeric arguments given.")); -} -?> \ No newline at end of file diff --git a/api/notify_schedule_group_play.php b/api/notify_schedule_group_play.php deleted file mode 100644 index 7527892bb..000000000 --- a/api/notify_schedule_group_play.php +++ /dev/null @@ -1,35 +0,0 @@ -exists()) { - $result = $sg->notifyGroupStartPlay(); - if (!PEAR::isError($result)) { - echo json_encode(array("status"=>1, "message"=>"")); - exit; - } else { - echo json_encode(array("status"=>0, "message"=>"DB Error:".$result->getMessage())); - exit; - } - } else { - echo json_encode(array("status"=>0, "message"=>"Schedule group does not exist: ".$schedule_group_id)); - exit; - } -} else { - echo json_encode(array("status"=>0, "message"=>"Incorrect or non-numeric arguments given.")); - exit; -} -?> \ No newline at end of file diff --git a/api/schedule.php b/api/schedule.php deleted file mode 100644 index 2009cf4d8..000000000 --- a/api/schedule.php +++ /dev/null @@ -1,18 +0,0 @@ - \ No newline at end of file From d7c0f5cc159dd3283f814f1e585fa8d0aaf5158a Mon Sep 17 00:00:00 2001 From: mkonecny Date: Wed, 15 Dec 2010 16:38:38 -0500 Subject: [PATCH 2/2] added simple unit tests for pypo. --- pypo/config.cfg | 4 ++-- pypo/logging-api-validator.cfg | 16 ++++++++-------- pypo/pypo-api-validator.py | 24 ++++++++++++++++++++++++ pypo/pypo-cli.py | 4 ++-- 4 files changed, 36 insertions(+), 12 deletions(-) mode change 100644 => 100755 pypo/pypo-api-validator.py diff --git a/pypo/config.cfg b/pypo/config.cfg index 7655854f0..5d012356c 100644 --- a/pypo/config.cfg +++ b/pypo/config.cfg @@ -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' diff --git a/pypo/logging-api-validator.cfg b/pypo/logging-api-validator.cfg index f564cf5b8..574196d5f 100644 --- a/pypo/logging-api-validator.cfg +++ b/pypo/logging-api-validator.cfg @@ -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] diff --git a/pypo/pypo-api-validator.py b/pypo/pypo-api-validator.py old mode 100644 new mode 100755 index 9f5a6d7fd..f5c85e317 --- a/pypo/pypo-api-validator.py +++ b/pypo/pypo-api-validator.py @@ -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() diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py index fbee1eaa7..3ef5fd095 100755 --- a/pypo/pypo-cli.py +++ b/pypo/pypo-cli.py @@ -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"