-reorganized/cleaned up python_apps/pypo directory.

This commit is contained in:
martin 2011-06-14 14:37:09 -04:00
parent f66305e3d3
commit 9cfec2c8ef
42 changed files with 14 additions and 338 deletions

View file

@ -0,0 +1,59 @@
[loggers]
keys=root
[handlers]
keys=consoleHandler,fileHandlerERROR,fileHandlerDEBUG,nullHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=consoleHandler,fileHandlerERROR,fileHandlerDEBUG
[logger_libs]
handlers=nullHandler
level=CRITICAL
qualname="process"
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=CRITICAL
formatter=simpleFormatter
args=(sys.stdout,)
[handler_fileHandlerERROR]
class=FileHandler
level=CRITICAL
formatter=simpleFormatter
args=("./error-unit-test.log",)
[handler_fileHandlerDEBUG]
class=FileHandler
level=CRITICAL
formatter=simpleFormatter
args=("./debug-unit-test.log",)
[handler_nullHandler]
class=FileHandler
level=CRITICAL
formatter=simpleFormatter
args=("./log-null-unit-test.log",)
[formatter_simpleFormatter]
format=%(asctime)s %(levelname)s - [%(filename)s : %(funcName)s() : line %(lineno)d] - %(message)s
datefmt=
## multitail color sheme
## pyml / python
# colorscheme:pyml:www.obp.net
# cs_re:blue:\[[^ ]*\]
# cs_re:red:CRITICAL:*
# cs_re:red,black,blink:ERROR:*
# cs_re:blue:NOTICE:*
# cs_re:cyan:INFO:*
# cs_re:green:DEBUG:*

View file

@ -0,0 +1,74 @@
import time
import os
import traceback
from optparse import *
import sys
import time
import datetime
import logging
import logging.config
import shutil
import urllib
import urllib2
import pickle
import telnetlib
import random
import string
import operator
import inspect
# additional modules (should be checked)
from configobj import ConfigObj
# custom imports
from util import *
from api_clients import *
import random
import unittest
# configure logging
logging.config.fileConfig("logging-api-validator.cfg")
try:
config = ConfigObj('/etc/airtime/pypo.cfg')
except Exception, e:
print 'Error loading config file: ', e
sys.exit()
class TestApiFunctions(unittest.TestCase):
def setUp(self):
self.api_client = api_client.api_client_factory(config)
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

@ -0,0 +1,42 @@
import unittest
from util.cue_file import CueFile
from mutagen.mp3 import MP3
from mutagen.oggvorbis import OggVorbis
import random
import string
class test(unittest.TestCase):
"""
A test class for the cue_in module.
"""
def setUp(self):
self.cue_file = CueFile()
def test_cue_mp3(self):
src = '../audio_samples/OpSound/Peter_Rudenko_-_Opening.mp3'
dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.mp3'
self.cue_file.cue(src, dst, 5, 5)
src_length = MP3(src).info.length
dst_length = MP3(dst).info.length
print src + " " + str(src_length)
print dst + " " + str(dst_length)
self.assertTrue(dst_length < src_length)
def test_cue_ogg(self):
src = '../audio_samples/OpSound/ACDC_-_Back_In_Black-sample.ogg'
dst = '/tmp/' + "".join([random.choice(string.letters) for i in xrange(10)]) + '.ogg'
self.cue_file.cue(src, dst, 5, 5)
src_length = OggVorbis(src).info.length
dst_length = OggVorbis(dst).info.length
print src + " " + str(src_length)
print dst + " " + str(dst_length)
self.assertTrue(dst_length < src_length)
if __name__ == '__main__':
unittest.main()