mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
parent
c6992a4726
commit
8275966db0
@ -53,7 +53,6 @@ You'll need these to run Supysonic:
|
||||
* [Flask](http://flask.pocoo.org/) >= 0.9
|
||||
* [PonyORM](https://ponyorm.com/)
|
||||
* [Python Imaging Library](https://github.com/python-pillow/Pillow)
|
||||
* [simplejson](https://simplejson.readthedocs.io/en/latest/)
|
||||
* [requests](http://docs.python-requests.org/)
|
||||
* [mutagen](https://mutagen.readthedocs.io/en/latest/)
|
||||
* [watchdog](https://github.com/gorakhargosh/watchdog)
|
||||
|
@ -1,7 +1,6 @@
|
||||
flask>=0.9
|
||||
pony
|
||||
Pillow
|
||||
simplejson
|
||||
requests>=1.0.0
|
||||
mutagen
|
||||
watchdog
|
||||
|
@ -19,10 +19,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import binascii
|
||||
import simplejson
|
||||
import uuid
|
||||
|
||||
from flask import request, current_app as app
|
||||
from flask import request, json, current_app as app
|
||||
from pony.orm import db_session, ObjectNotFound
|
||||
from xml.dom import minidom
|
||||
from xml.etree import ElementTree
|
||||
@ -163,11 +162,11 @@ class ResponseHelper:
|
||||
status = 'failed' if error else 'ok',
|
||||
version = version
|
||||
)
|
||||
return simplejson.dumps({ 'subsonic-response': ret }, indent = True, encoding = 'utf-8')
|
||||
return json.dumps({ 'subsonic-response': ret }, indent = True)
|
||||
|
||||
@staticmethod
|
||||
def responsize_jsonp(ret, callback, error = False, version = "1.8.0"):
|
||||
return "%s(%s)" % (callback, ResponseHelper.responsize_json(ret, error, version))
|
||||
return '{}({})'.format(callback, ResponseHelper.responsize_json(ret, error, version))
|
||||
|
||||
@staticmethod
|
||||
def responsize_xml(ret, error = False, version = "1.8.0"):
|
||||
|
@ -11,7 +11,7 @@
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import base64
|
||||
import simplejson
|
||||
import flask.json
|
||||
|
||||
from xml.etree import ElementTree
|
||||
|
||||
@ -104,7 +104,7 @@ class ApiSetupTestCase(TestBase):
|
||||
rv = self.client.get('/rest/getLicense.view', query_string = args)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
self.assertEqual(rv.mimetype, 'application/json')
|
||||
json = simplejson.loads(rv.data)
|
||||
json = flask.json.loads(rv.data)
|
||||
self.assertIn('subsonic-response', json)
|
||||
self.assertEqual(json['subsonic-response']['status'], 'ok')
|
||||
self.assertIn('license', json['subsonic-response'])
|
||||
@ -112,7 +112,7 @@ class ApiSetupTestCase(TestBase):
|
||||
args.update({ 'f': 'jsonp' })
|
||||
rv = self.client.get('/rest/getLicense.view', query_string = args)
|
||||
self.assertEqual(rv.mimetype, 'application/javascript')
|
||||
json = simplejson.loads(rv.data)
|
||||
json = flask.json.loads(rv.data)
|
||||
self.assertIn('subsonic-response', json)
|
||||
self.assertEqual(json['subsonic-response']['status'], 'failed')
|
||||
self.assertEqual(json['subsonic-response']['error']['code'], 10)
|
||||
@ -123,7 +123,7 @@ class ApiSetupTestCase(TestBase):
|
||||
self.assertEqual(rv.mimetype, 'application/javascript')
|
||||
self.assertTrue(rv.data.startswith('dummy_cb({'))
|
||||
self.assertTrue(rv.data.endswith('})'))
|
||||
json = simplejson.loads(rv.data[9:-1])
|
||||
json = flask.json.loads(rv.data[9:-1])
|
||||
self.assertIn('subsonic-response', json)
|
||||
self.assertEqual(json['subsonic-response']['status'], 'ok')
|
||||
self.assertIn('license', json['subsonic-response'])
|
||||
|
@ -10,8 +10,8 @@
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import unittest
|
||||
import flask.json
|
||||
|
||||
import simplejson
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from supysonic.py23 import strtype
|
||||
@ -31,7 +31,7 @@ class ResponseHelperJsonTestCase(ResponseHelperBaseCase):
|
||||
raise TypeError('Invalid tested value, expecting a dict')
|
||||
|
||||
json = self.helper.responsize_json(d, error)
|
||||
return simplejson.loads(json)
|
||||
return flask.json.loads(json)
|
||||
|
||||
def process_and_extract(self, d, error = False):
|
||||
# Basically returns d with additional version and status
|
||||
@ -123,7 +123,7 @@ class ResponseHelperJsonpTestCase(ResponseHelperBaseCase):
|
||||
self.assertTrue(result.startswith('callback({'))
|
||||
self.assertTrue(result.endswith('})'))
|
||||
|
||||
json = simplejson.loads(result[9:-1])
|
||||
json = flask.json.loads(result[9:-1])
|
||||
self.assertIn('subsonic-response', json)
|
||||
|
||||
class ResponseHelperXMLTestCase(ResponseHelperBaseCase):
|
||||
|
Loading…
Reference in New Issue
Block a user