Fix too broad truthness test (fix #501)
This caused TlTracks with tlid=0 to be sent to HTTP clients without the tlid field.
This commit is contained in:
parent
713cd598d0
commit
e830f31480
@ -64,6 +64,12 @@ v0.15.0 (UNRELEASED)
|
||||
The methods are still not implemented, but now the commands are accepted as
|
||||
valid.
|
||||
|
||||
**HTTP frontend**
|
||||
|
||||
- Fix too broad truthness test that caused :class:`~mopidy.models.TlTrack`
|
||||
objects with ``tlid`` set to ``0`` to be sent to the HTTP client without the
|
||||
``tlid`` field. (Fixes: :issue:`501`)
|
||||
|
||||
**Extension support**
|
||||
|
||||
- :class:`~mopidy.config.Secret` is now deserialized to unicode strings instead
|
||||
|
||||
@ -90,7 +90,7 @@ class ImmutableObject(object):
|
||||
for v in value]
|
||||
elif isinstance(value, ImmutableObject):
|
||||
value = value.serialize()
|
||||
if value:
|
||||
if not (isinstance(value, list) and len(value) == 0):
|
||||
data[public_key] = value
|
||||
return data
|
||||
|
||||
|
||||
@ -95,6 +95,11 @@ class ArtistTest(unittest.TestCase):
|
||||
{'__model__': 'Artist', 'uri': 'uri', 'name': 'name'},
|
||||
Artist(uri='uri', name='name').serialize())
|
||||
|
||||
def test_serialize_falsy_values(self):
|
||||
self.assertDictEqual(
|
||||
{'__model__': 'Artist', 'uri': '', 'name': None},
|
||||
Artist(uri='', name=None).serialize())
|
||||
|
||||
def test_to_json_and_back(self):
|
||||
artist1 = Artist(uri='uri', name='name')
|
||||
serialized = json.dumps(artist1, cls=ModelJSONEncoder)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user