Remove hacks required by #302 to run on older Python 2.6.x
This commit is contained in:
parent
52ee456692
commit
de84fdfef4
@ -140,35 +140,33 @@ def parse_options():
|
|||||||
optparse.Option.TYPES += ('config_override',)
|
optparse.Option.TYPES += ('config_override',)
|
||||||
optparse.Option.TYPE_CHECKER['config_override'] = check_config_override
|
optparse.Option.TYPE_CHECKER['config_override'] = check_config_override
|
||||||
|
|
||||||
# NOTE First argument to add_option must be bytestrings on Python < 2.6.2
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'-q', '--quiet',
|
'-q', '--quiet',
|
||||||
action='store_const', const=0, dest='verbosity_level',
|
action='store_const', const=0, dest='verbosity_level',
|
||||||
help='less output (warning level)')
|
help='less output (warning level)')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'-v', '--verbose',
|
'-v', '--verbose',
|
||||||
action='count', default=1, dest='verbosity_level',
|
action='count', default=1, dest='verbosity_level',
|
||||||
help='more output (debug level)')
|
help='more output (debug level)')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'--save-debug-log',
|
'--save-debug-log',
|
||||||
action='store_true', dest='save_debug_log',
|
action='store_true', dest='save_debug_log',
|
||||||
help='save debug log to "./mopidy.log"')
|
help='save debug log to "./mopidy.log"')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'--show-config',
|
'--show-config',
|
||||||
action='callback', callback=show_config_callback,
|
action='callback', callback=show_config_callback,
|
||||||
help='show current config')
|
help='show current config')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'--show-deps',
|
'--show-deps',
|
||||||
action='callback', callback=deps.show_deps_optparse_callback,
|
action='callback', callback=deps.show_deps_optparse_callback,
|
||||||
help='show dependencies and their versions')
|
help='show dependencies and their versions')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'--config',
|
'--config',
|
||||||
action='store', dest='config',
|
action='store', dest='config',
|
||||||
default=b'$XDG_CONFIG_DIR/mopidy/mopidy.conf',
|
default=b'$XDG_CONFIG_DIR/mopidy/mopidy.conf',
|
||||||
help='config files to use, colon seperated, later files override')
|
help='config files to use, colon seperated, later files override')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'-o', b'--option',
|
'-o', '--option',
|
||||||
action='append', dest='overrides', type='config_override',
|
action='append', dest='overrides', type='config_override',
|
||||||
help='`section/key=value` values to override config options')
|
help='`section/key=value` values to override config options')
|
||||||
return parser.parse_args(args=mopidy_args)[0]
|
return parser.parse_args(args=mopidy_args)[0]
|
||||||
|
|||||||
@ -100,9 +100,6 @@ def _convert_mpd_data(data, tracks, music_dir):
|
|||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
|
|
||||||
track_kwargs = {}
|
track_kwargs = {}
|
||||||
album_kwargs = {}
|
album_kwargs = {}
|
||||||
artist_kwargs = {}
|
artist_kwargs = {}
|
||||||
@ -110,51 +107,51 @@ def _convert_mpd_data(data, tracks, music_dir):
|
|||||||
|
|
||||||
if 'track' in data:
|
if 'track' in data:
|
||||||
if '/' in data['track']:
|
if '/' in data['track']:
|
||||||
album_kwargs[b'num_tracks'] = int(data['track'].split('/')[1])
|
album_kwargs['num_tracks'] = int(data['track'].split('/')[1])
|
||||||
track_kwargs[b'track_no'] = int(data['track'].split('/')[0])
|
track_kwargs['track_no'] = int(data['track'].split('/')[0])
|
||||||
else:
|
else:
|
||||||
track_kwargs[b'track_no'] = int(data['track'])
|
track_kwargs['track_no'] = int(data['track'])
|
||||||
|
|
||||||
if 'artist' in data:
|
if 'artist' in data:
|
||||||
artist_kwargs[b'name'] = data['artist']
|
artist_kwargs['name'] = data['artist']
|
||||||
albumartist_kwargs[b'name'] = data['artist']
|
albumartist_kwargs['name'] = data['artist']
|
||||||
|
|
||||||
if 'albumartist' in data:
|
if 'albumartist' in data:
|
||||||
albumartist_kwargs[b'name'] = data['albumartist']
|
albumartist_kwargs['name'] = data['albumartist']
|
||||||
|
|
||||||
if 'album' in data:
|
if 'album' in data:
|
||||||
album_kwargs[b'name'] = data['album']
|
album_kwargs['name'] = data['album']
|
||||||
|
|
||||||
if 'title' in data:
|
if 'title' in data:
|
||||||
track_kwargs[b'name'] = data['title']
|
track_kwargs['name'] = data['title']
|
||||||
|
|
||||||
if 'date' in data:
|
if 'date' in data:
|
||||||
track_kwargs[b'date'] = data['date']
|
track_kwargs['date'] = data['date']
|
||||||
|
|
||||||
if 'musicbrainz_trackid' in data:
|
if 'musicbrainz_trackid' in data:
|
||||||
track_kwargs[b'musicbrainz_id'] = data['musicbrainz_trackid']
|
track_kwargs['musicbrainz_id'] = data['musicbrainz_trackid']
|
||||||
|
|
||||||
if 'musicbrainz_albumid' in data:
|
if 'musicbrainz_albumid' in data:
|
||||||
album_kwargs[b'musicbrainz_id'] = data['musicbrainz_albumid']
|
album_kwargs['musicbrainz_id'] = data['musicbrainz_albumid']
|
||||||
|
|
||||||
if 'musicbrainz_artistid' in data:
|
if 'musicbrainz_artistid' in data:
|
||||||
artist_kwargs[b'musicbrainz_id'] = data['musicbrainz_artistid']
|
artist_kwargs['musicbrainz_id'] = data['musicbrainz_artistid']
|
||||||
|
|
||||||
if 'musicbrainz_albumartistid' in data:
|
if 'musicbrainz_albumartistid' in data:
|
||||||
albumartist_kwargs[b'musicbrainz_id'] = (
|
albumartist_kwargs['musicbrainz_id'] = (
|
||||||
data['musicbrainz_albumartistid'])
|
data['musicbrainz_albumartistid'])
|
||||||
|
|
||||||
if artist_kwargs:
|
if artist_kwargs:
|
||||||
artist = Artist(**artist_kwargs)
|
artist = Artist(**artist_kwargs)
|
||||||
track_kwargs[b'artists'] = [artist]
|
track_kwargs['artists'] = [artist]
|
||||||
|
|
||||||
if albumartist_kwargs:
|
if albumartist_kwargs:
|
||||||
albumartist = Artist(**albumartist_kwargs)
|
albumartist = Artist(**albumartist_kwargs)
|
||||||
album_kwargs[b'artists'] = [albumartist]
|
album_kwargs['artists'] = [albumartist]
|
||||||
|
|
||||||
if album_kwargs:
|
if album_kwargs:
|
||||||
album = Album(**album_kwargs)
|
album = Album(**album_kwargs)
|
||||||
track_kwargs[b'album'] = album
|
track_kwargs['album'] = album
|
||||||
|
|
||||||
if data['file'][0] == '/':
|
if data['file'][0] == '/':
|
||||||
path = data['file'][1:]
|
path = data['file'][1:]
|
||||||
@ -167,9 +164,9 @@ def _convert_mpd_data(data, tracks, music_dir):
|
|||||||
|
|
||||||
# Make sure we only pass bytestrings to path_to_uri to avoid implicit
|
# Make sure we only pass bytestrings to path_to_uri to avoid implicit
|
||||||
# decoding of bytestrings to unicode strings
|
# decoding of bytestrings to unicode strings
|
||||||
track_kwargs[b'uri'] = path_to_uri(music_dir, path)
|
track_kwargs['uri'] = path_to_uri(music_dir, path)
|
||||||
|
|
||||||
track_kwargs[b'length'] = int(data.get('time', 0)) * 1000
|
track_kwargs['length'] = int(data.get('time', 0)) * 1000
|
||||||
|
|
||||||
track = Track(**track_kwargs)
|
track = Track(**track_kwargs)
|
||||||
tracks.add(track)
|
tracks.add(track)
|
||||||
|
|||||||
@ -18,15 +18,13 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener):
|
|||||||
hostname = network.format_hostname(config['mpd']['hostname'])
|
hostname = network.format_hostname(config['mpd']['hostname'])
|
||||||
port = config['mpd']['port']
|
port = config['mpd']['port']
|
||||||
|
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
try:
|
try:
|
||||||
network.Server(
|
network.Server(
|
||||||
hostname, port,
|
hostname, port,
|
||||||
protocol=session.MpdSession,
|
protocol=session.MpdSession,
|
||||||
protocol_kwargs={
|
protocol_kwargs={
|
||||||
b'config': config,
|
'config': config,
|
||||||
b'core': core,
|
'core': core,
|
||||||
},
|
},
|
||||||
max_connections=config['mpd']['max_connections'],
|
max_connections=config['mpd']['max_connections'],
|
||||||
timeout=config['mpd']['connection_timeout'])
|
timeout=config['mpd']['connection_timeout'])
|
||||||
|
|||||||
@ -56,12 +56,7 @@ def handle_request(pattern, auth_required=True):
|
|||||||
if match is not None:
|
if match is not None:
|
||||||
mpd_commands.add(
|
mpd_commands.add(
|
||||||
MpdCommand(name=match.group(), auth_required=auth_required))
|
MpdCommand(name=match.group(), auth_required=auth_required))
|
||||||
# NOTE Make pattern a bytestring to get bytestring keys in the dict
|
compiled_pattern = re.compile(pattern, flags=re.UNICODE)
|
||||||
# returned from matches.groupdict(), which is again used as a **kwargs
|
|
||||||
# dict. This is needed to work on Python < 2.6.5.
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
bytestring_pattern = pattern.encode('utf-8')
|
|
||||||
compiled_pattern = re.compile(bytestring_pattern, flags=re.UNICODE)
|
|
||||||
if compiled_pattern in request_handlers:
|
if compiled_pattern in request_handlers:
|
||||||
raise ValueError('Tried to redefine handler for %s with %s' % (
|
raise ValueError('Tried to redefine handler for %s with %s' % (
|
||||||
pattern, func))
|
pattern, func))
|
||||||
|
|||||||
@ -139,8 +139,6 @@ def query_from_mpd_list_format(field, mpd_query):
|
|||||||
"""
|
"""
|
||||||
Converts an MPD ``list`` query to a Mopidy query.
|
Converts an MPD ``list`` query to a Mopidy query.
|
||||||
"""
|
"""
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
if mpd_query is None:
|
if mpd_query is None:
|
||||||
return {}
|
return {}
|
||||||
try:
|
try:
|
||||||
@ -156,7 +154,7 @@ def query_from_mpd_list_format(field, mpd_query):
|
|||||||
if field == 'album':
|
if field == 'album':
|
||||||
if not tokens[0]:
|
if not tokens[0]:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return {b'artist': [tokens[0]]} # See above NOTE
|
return {'artist': [tokens[0]]} # See above NOTE
|
||||||
else:
|
else:
|
||||||
raise MpdArgError(
|
raise MpdArgError(
|
||||||
'should be "Album" for 3 arguments', command='list')
|
'should be "Album" for 3 arguments', command='list')
|
||||||
|
|||||||
@ -66,15 +66,13 @@ class ImmutableObject(object):
|
|||||||
:type values: dict
|
:type values: dict
|
||||||
:rtype: new instance of the model being copied
|
:rtype: new instance of the model being copied
|
||||||
"""
|
"""
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
data = {}
|
data = {}
|
||||||
for key in self.__dict__.keys():
|
for key in self.__dict__.keys():
|
||||||
public_key = key.lstrip('_')
|
public_key = key.lstrip('_')
|
||||||
data[str(public_key)] = values.pop(public_key, self.__dict__[key])
|
data[public_key] = values.pop(public_key, self.__dict__[key])
|
||||||
for key in values.keys():
|
for key in values.keys():
|
||||||
if hasattr(self, key):
|
if hasattr(self, key):
|
||||||
data[str(key)] = values.pop(key)
|
data[key] = values.pop(key)
|
||||||
if values:
|
if values:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
'copy() got an unexpected keyword argument "%s"' % key)
|
'copy() got an unexpected keyword argument "%s"' % key)
|
||||||
@ -127,15 +125,13 @@ def model_json_decoder(dct):
|
|||||||
{u'a_track': Track(artists=[], name=u'name')}
|
{u'a_track': Track(artists=[], name=u'name')}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
if '__model__' in dct:
|
if '__model__' in dct:
|
||||||
model_name = dct.pop('__model__')
|
model_name = dct.pop('__model__')
|
||||||
cls = globals().get(model_name, None)
|
cls = globals().get(model_name, None)
|
||||||
if issubclass(cls, ImmutableObject):
|
if issubclass(cls, ImmutableObject):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for key, value in dct.items():
|
for key, value in dct.items():
|
||||||
kwargs[str(key)] = value
|
kwargs[key] = value
|
||||||
return cls(**kwargs)
|
return cls(**kwargs)
|
||||||
return dct
|
return dct
|
||||||
|
|
||||||
@ -208,10 +204,8 @@ class Album(ImmutableObject):
|
|||||||
# actual usage of this field with more than one image.
|
# actual usage of this field with more than one image.
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
self.__dict__['artists'] = frozenset(kwargs.pop('artists', []))
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
self.__dict__['images'] = frozenset(kwargs.pop('images', []))
|
||||||
self.__dict__[b'artists'] = frozenset(kwargs.pop('artists', []))
|
|
||||||
self.__dict__[b'images'] = frozenset(kwargs.pop('images', []))
|
|
||||||
super(Album, self).__init__(*args, **kwargs)
|
super(Album, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@ -270,9 +264,7 @@ class Track(ImmutableObject):
|
|||||||
musicbrainz_id = None
|
musicbrainz_id = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
self.__dict__['artists'] = frozenset(kwargs.pop('artists', []))
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
self.__dict__[b'artists'] = frozenset(kwargs.pop('artists', []))
|
|
||||||
super(Track, self).__init__(*args, **kwargs)
|
super(Track, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@ -304,11 +296,9 @@ class TlTrack(ImmutableObject):
|
|||||||
track = None
|
track = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
if len(args) == 2 and len(kwargs) == 0:
|
if len(args) == 2 and len(kwargs) == 0:
|
||||||
kwargs[b'tlid'] = args[0]
|
kwargs['tlid'] = args[0]
|
||||||
kwargs[b'track'] = args[1]
|
kwargs['track'] = args[1]
|
||||||
args = []
|
args = []
|
||||||
super(TlTrack, self).__init__(*args, **kwargs)
|
super(TlTrack, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
@ -343,9 +333,7 @@ class Playlist(ImmutableObject):
|
|||||||
last_modified = None
|
last_modified = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
self.__dict__['tracks'] = tuple(kwargs.pop('tracks', []))
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
self.__dict__[b'tracks'] = tuple(kwargs.pop('tracks', []))
|
|
||||||
super(Playlist, self).__init__(*args, **kwargs)
|
super(Playlist, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
# TODO: def insert(self, pos, track): ... ?
|
# TODO: def insert(self, pos, track): ... ?
|
||||||
@ -381,9 +369,7 @@ class SearchResult(ImmutableObject):
|
|||||||
albums = tuple()
|
albums = tuple()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
self.__dict__['tracks'] = tuple(kwargs.pop('tracks', []))
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
self.__dict__['artists'] = tuple(kwargs.pop('artists', []))
|
||||||
self.__dict__[b'tracks'] = tuple(kwargs.pop('tracks', []))
|
self.__dict__['albums'] = tuple(kwargs.pop('albums', []))
|
||||||
self.__dict__[b'artists'] = tuple(kwargs.pop('artists', []))
|
|
||||||
self.__dict__[b'albums'] = tuple(kwargs.pop('albums', []))
|
|
||||||
super(SearchResult, self).__init__(*args, **kwargs)
|
super(SearchResult, self).__init__(*args, **kwargs)
|
||||||
|
|||||||
@ -90,14 +90,12 @@ def main():
|
|||||||
def parse_options():
|
def parse_options():
|
||||||
parser = optparse.OptionParser(
|
parser = optparse.OptionParser(
|
||||||
version='Mopidy %s' % versioning.get_version())
|
version='Mopidy %s' % versioning.get_version())
|
||||||
# NOTE First argument to add_option must be bytestrings on Python < 2.6.2
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details
|
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'-q', '--quiet',
|
'-q', '--quiet',
|
||||||
action='store_const', const=0, dest='verbosity_level',
|
action='store_const', const=0, dest='verbosity_level',
|
||||||
help='less output (warning level)')
|
help='less output (warning level)')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
b'-v', '--verbose',
|
'-v', '--verbose',
|
||||||
action='count', default=1, dest='verbosity_level',
|
action='count', default=1, dest='verbosity_level',
|
||||||
help='more output (debug level)')
|
help='more output (debug level)')
|
||||||
return parser.parse_args(args=mopidy_args)[0]
|
return parser.parse_args(args=mopidy_args)[0]
|
||||||
@ -109,12 +107,9 @@ def translator(data):
|
|||||||
artist_kwargs = {}
|
artist_kwargs = {}
|
||||||
track_kwargs = {}
|
track_kwargs = {}
|
||||||
|
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
|
|
||||||
def _retrieve(source_key, target_key, target):
|
def _retrieve(source_key, target_key, target):
|
||||||
if source_key in data:
|
if source_key in data:
|
||||||
target[str(target_key)] = data[source_key]
|
target[target_key] = data[source_key]
|
||||||
|
|
||||||
_retrieve(gst.TAG_ALBUM, 'name', album_kwargs)
|
_retrieve(gst.TAG_ALBUM, 'name', album_kwargs)
|
||||||
_retrieve(gst.TAG_TRACK_COUNT, 'num_tracks', album_kwargs)
|
_retrieve(gst.TAG_TRACK_COUNT, 'num_tracks', album_kwargs)
|
||||||
@ -127,7 +122,7 @@ def translator(data):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass # Ignore invalid dates
|
pass # Ignore invalid dates
|
||||||
else:
|
else:
|
||||||
track_kwargs[b'date'] = date.isoformat()
|
track_kwargs['date'] = date.isoformat()
|
||||||
|
|
||||||
_retrieve(gst.TAG_TITLE, 'name', track_kwargs)
|
_retrieve(gst.TAG_TITLE, 'name', track_kwargs)
|
||||||
_retrieve(gst.TAG_TRACK_NUMBER, 'track_no', track_kwargs)
|
_retrieve(gst.TAG_TRACK_NUMBER, 'track_no', track_kwargs)
|
||||||
@ -141,12 +136,12 @@ def translator(data):
|
|||||||
'musicbrainz-albumartistid', 'musicbrainz_id', albumartist_kwargs)
|
'musicbrainz-albumartistid', 'musicbrainz_id', albumartist_kwargs)
|
||||||
|
|
||||||
if albumartist_kwargs:
|
if albumartist_kwargs:
|
||||||
album_kwargs[b'artists'] = [Artist(**albumartist_kwargs)]
|
album_kwargs['artists'] = [Artist(**albumartist_kwargs)]
|
||||||
|
|
||||||
track_kwargs[b'uri'] = data['uri']
|
track_kwargs['uri'] = data['uri']
|
||||||
track_kwargs[b'length'] = data[gst.TAG_DURATION]
|
track_kwargs['length'] = data[gst.TAG_DURATION]
|
||||||
track_kwargs[b'album'] = Album(**album_kwargs)
|
track_kwargs['album'] = Album(**album_kwargs)
|
||||||
track_kwargs[b'artists'] = [Artist(**artist_kwargs)]
|
track_kwargs['artists'] = [Artist(**artist_kwargs)]
|
||||||
|
|
||||||
return Track(**track_kwargs)
|
return Track(**track_kwargs)
|
||||||
|
|
||||||
|
|||||||
@ -34,40 +34,36 @@ class TranslatorTest(unittest.TestCase):
|
|||||||
'musicbrainz-albumartistid': 'mbalbumartistid',
|
'musicbrainz-albumartistid': 'mbalbumartistid',
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE: kwargs are explicitly made bytestrings to work on Python
|
|
||||||
# 2.6.0/2.6.1. See https://github.com/mopidy/mopidy/issues/302 for
|
|
||||||
# details.
|
|
||||||
|
|
||||||
self.album = {
|
self.album = {
|
||||||
b'name': 'albumname',
|
'name': 'albumname',
|
||||||
b'num_tracks': 2,
|
'num_tracks': 2,
|
||||||
b'musicbrainz_id': 'mbalbumid',
|
'musicbrainz_id': 'mbalbumid',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.artist = {
|
self.artist = {
|
||||||
b'name': 'name',
|
'name': 'name',
|
||||||
b'musicbrainz_id': 'mbartistid',
|
'musicbrainz_id': 'mbartistid',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.albumartist = {
|
self.albumartist = {
|
||||||
b'name': 'albumartistname',
|
'name': 'albumartistname',
|
||||||
b'musicbrainz_id': 'mbalbumartistid',
|
'musicbrainz_id': 'mbalbumartistid',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.track = {
|
self.track = {
|
||||||
b'uri': 'uri',
|
'uri': 'uri',
|
||||||
b'name': 'trackname',
|
'name': 'trackname',
|
||||||
b'date': '2006-01-01',
|
'date': '2006-01-01',
|
||||||
b'track_no': 1,
|
'track_no': 1,
|
||||||
b'length': 4531,
|
'length': 4531,
|
||||||
b'musicbrainz_id': 'mbtrackid',
|
'musicbrainz_id': 'mbtrackid',
|
||||||
}
|
}
|
||||||
|
|
||||||
def build_track(self):
|
def build_track(self):
|
||||||
if self.albumartist:
|
if self.albumartist:
|
||||||
self.album[b'artists'] = [Artist(**self.albumartist)]
|
self.album['artists'] = [Artist(**self.albumartist)]
|
||||||
self.track[b'album'] = Album(**self.album)
|
self.track['album'] = Album(**self.album)
|
||||||
self.track[b'artists'] = [Artist(**self.artist)]
|
self.track['artists'] = [Artist(**self.artist)]
|
||||||
return Track(**self.track)
|
return Track(**self.track)
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
|
|||||||
@ -218,12 +218,10 @@ class JsonRpcSingleCommandTest(JsonRpcTestBase):
|
|||||||
self.assertEqual(self.core.playback.get_volume().get(), 37)
|
self.assertEqual(self.core.playback.get_volume().get(), 37)
|
||||||
|
|
||||||
def test_call_methods_with_named_params(self):
|
def test_call_methods_with_named_params(self):
|
||||||
# NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
|
|
||||||
# See https://github.com/mopidy/mopidy/issues/302 for details.
|
|
||||||
request = {
|
request = {
|
||||||
'jsonrpc': '2.0',
|
'jsonrpc': '2.0',
|
||||||
'method': 'core.playback.set_volume',
|
'method': 'core.playback.set_volume',
|
||||||
'params': {b'volume': 37},
|
'params': {'volume': 37},
|
||||||
'id': 1,
|
'id': 1,
|
||||||
}
|
}
|
||||||
response = self.jrw.handle_data(request)
|
response = self.jrw.handle_data(request)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user