Fix tests
This commit is contained in:
parent
6213604341
commit
e8a0783139
|
@ -17,17 +17,7 @@ setup(name='api_clients',
|
|||
packages=['api_clients'],
|
||||
scripts=[],
|
||||
install_requires=[
|
||||
# 'amqplib',
|
||||
# 'anyjson',
|
||||
# 'argparse',
|
||||
'configobj'
|
||||
# 'docopt',
|
||||
# 'kombu',
|
||||
# 'mutagen',
|
||||
# 'poster3',
|
||||
# 'PyDispatcher',
|
||||
# 'pyinotify',
|
||||
# 'pytz',
|
||||
],
|
||||
zip_safe=False,
|
||||
data_files=[])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import unittest
|
||||
from .. api_client import ApcUrl, UrlBadParam, IncompleteUrl
|
||||
from api_clients.api_client import ApcUrl, UrlBadParam, IncompleteUrl
|
||||
|
||||
class TestApcUrl(unittest.TestCase):
|
||||
def test_init(self):
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
import unittest
|
||||
import json
|
||||
from mock import MagicMock, patch
|
||||
from .. api_client import ApcUrl, ApiRequest
|
||||
from api_clients.api_client import ApcUrl, ApiRequest
|
||||
|
||||
class ResponseInfo:
|
||||
def getheader(self, name):
|
||||
return 'application/json'
|
||||
|
||||
class TestApiRequest(unittest.TestCase):
|
||||
def test_init(self):
|
||||
|
@ -12,8 +16,9 @@ class TestApiRequest(unittest.TestCase):
|
|||
ret = json.dumps( {'ok':'ok'} )
|
||||
read = MagicMock()
|
||||
read.read = MagicMock(return_value=ret)
|
||||
u = '/testing'
|
||||
with patch('urllib2.urlopen') as mock_method:
|
||||
read.info = MagicMock(return_value=ResponseInfo())
|
||||
u = 'http://localhost/testing'
|
||||
with patch('urllib.request.urlopen') as mock_method:
|
||||
mock_method.return_value = read
|
||||
request = ApiRequest('mm', ApcUrl(u))()
|
||||
self.assertEqual(request, json.loads(ret))
|
||||
|
|
|
@ -2,13 +2,19 @@ import unittest
|
|||
import json
|
||||
from mock import patch, MagicMock
|
||||
from configobj import ConfigObj
|
||||
from .. api_client import RequestProvider
|
||||
from api_clients.api_client import RequestProvider, api_config
|
||||
|
||||
class TestRequestProvider(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.cfg = ConfigObj('api_client.cfg')
|
||||
self.cfg = api_config
|
||||
self.cfg['general'] = {}
|
||||
self.cfg['general']['base_dir'] = '/test'
|
||||
self.cfg['general']['base_port'] = 80
|
||||
self.cfg['general']['base_url'] = 'localhost'
|
||||
self.cfg['general']['api_key'] = 'TEST_KEY'
|
||||
self.cfg['api_base'] = 'api'
|
||||
def test_test(self):
|
||||
self.assertTrue('api_key' in self.cfg)
|
||||
self.assertTrue('general' in self.cfg)
|
||||
def test_init(self):
|
||||
rp = RequestProvider(self.cfg)
|
||||
self.assertTrue( len( rp.available_requests() ) > 0 )
|
||||
|
@ -16,17 +22,6 @@ class TestRequestProvider(unittest.TestCase):
|
|||
rp = RequestProvider(self.cfg)
|
||||
methods = ['upload_recorded', 'update_media_url', 'list_all_db_files']
|
||||
for meth in methods:
|
||||
self.assertTrue( meth in rp )
|
||||
|
||||
def test_notify_webstream_data(self):
|
||||
ret = json.dumps( {'testing' : '123' } )
|
||||
rp = RequestProvider(self.cfg)
|
||||
read = MagicMock()
|
||||
read.read = MagicMock(return_value=ret)
|
||||
with patch('urllib2.urlopen') as mock_method:
|
||||
mock_method.return_value = read
|
||||
response = rp.notify_webstream_data(media_id=123)
|
||||
mock_method.called_once_with(media_id=123)
|
||||
self.assertEqual(json.loads(ret), response)
|
||||
self.assertTrue( meth in rp.requests )
|
||||
|
||||
if __name__ == '__main__': unittest.main()
|
||||
|
|
|
@ -125,7 +125,7 @@ class PypoLiquidsoap():
|
|||
scheduled_now_webstream = \
|
||||
[x for x in scheduled_now if x["type"] == eventtypes.STREAM_OUTPUT_START]
|
||||
|
||||
schedule_ids = {x["row_id"] for x in scheduled_now_files]}
|
||||
schedule_ids = [x["row_id"] for x in scheduled_now_files]
|
||||
|
||||
row_id_map = {}
|
||||
liq_queue_ids = set()
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
which py.test
|
||||
pytest_exist=$?
|
||||
|
||||
if [ "$pytest_exist" != "0" ]; then
|
||||
echo "Need to have py.test installed. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT=`readlink -f $0`
|
||||
# Absolute directory this script is in
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
export PYTHONPATH=$PYTHONPATH:$SCRIPTPATH/..:$SCRIPTPATH/../..
|
||||
|
||||
py.test
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
from pypopush import PypoPush
|
||||
from threading import Lock
|
||||
from queue import Queue
|
||||
|
||||
import datetime
|
||||
|
||||
pypoPush_q = Queue()
|
||||
telnet_lock = Lock()
|
||||
|
||||
pp = PypoPush(pypoPush_q, telnet_lock)
|
||||
|
||||
def test_modify_cue_in():
|
||||
link = pp.modify_first_link_cue_point([])
|
||||
assert len(link) == 0
|
||||
|
||||
min_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes = 1)
|
||||
link = [{"start":min_ago.strftime("%Y-%m-%d-%H-%M-%S"),
|
||||
"cue_in":"0", "cue_out":"30"}]
|
||||
link = pp.modify_first_link_cue_point(link)
|
||||
assert len(link) == 0
|
||||
|
||||
link = [{"start":min_ago.strftime("%Y-%m-%d-%H-%M-%S"),
|
||||
"cue_in":"0", "cue_out":"70"}]
|
||||
link = pp.modify_first_link_cue_point(link)
|
||||
assert len(link) == 1
|
||||
|
|
@ -15,11 +15,6 @@ pip3 install -e .
|
|||
nosetests
|
||||
popd
|
||||
|
||||
pushd python_apps/pypo
|
||||
pip3 install -e .
|
||||
nosetests
|
||||
popd
|
||||
|
||||
echo "Building docs..."
|
||||
mkdocs build --clean -q > /dev/null
|
||||
echo -n "done"
|
||||
|
|
Loading…
Reference in New Issue