models: Allow Ref.type to have any value

This is to address a potential breakage brought up in #1150 as it turns out
Mopidy-Podcast uses custom models and ref types.
This commit is contained in:
Thomas Adamcik 2015-04-28 22:58:15 +02:00
parent 97c336200b
commit 8851fb151c
2 changed files with 6 additions and 5 deletions

View File

@ -30,6 +30,11 @@ class Ref(ImmutableObject):
#: The object name. Read-only.
name = fields.String()
#: The object type, e.g. "artist", "album", "track", "playlist",
#: "directory". Read-only.
type = fields.Identifier() # TODO: consider locking this down.
# type = fields.Field(choices=(ALBUM, ARTIST, DIRECTORY, PLAYLIST, TRACK))
#: Constant used for comparison with the :attr:`type` field.
ALBUM = 'album'
@ -45,10 +50,6 @@ class Ref(ImmutableObject):
#: Constant used for comparison with the :attr:`type` field.
TRACK = 'track'
#: The object type, e.g. "artist", "album", "track", "playlist",
#: "directory". Read-only.
type = fields.Field(choices=(ALBUM, ARTIST, DIRECTORY, PLAYLIST, TRACK))
@classmethod
def album(cls, **kwargs):
"""Create a :class:`Ref` with ``type`` :attr:`ALBUM`."""

View File

@ -113,7 +113,7 @@ class RefTest(unittest.TestCase):
def test_repr_without_results(self):
self.assertEqual(
"Ref(name=u'foo', type=u'artist', uri='uri')",
"Ref(name=u'foo', type='artist', uri='uri')",
repr(Ref(uri='uri', name='foo', type='artist')))
def test_serialize_without_results(self):