def test_to_from(self): ml = MediaLibrary() s1 = song() ml.add_song(s1) ml.create_playlist("test") ml.add_song_to_playlist(s1.alias, "test") self.assertEqual(MediaLibrary.from_primitive(ml.to_primitive()), ml)
def test_empty_to_primitive(self): ml = MediaLibrary() self.assertEqual( ml.to_primitive(), { media_library.VERSION_FIELD: MediaLibrary.VERSION, MediaLibrary.SONGS_FIELD: [], MediaLibrary.PLAYLIST_FIELD: {} })
def test_filled_library_to_primitive(self): ml = MediaLibrary() s1 = song() ml.add_song(s1) ml.create_playlist("test") ml.add_song_to_playlist(s1.alias, "test") self.assertEqual( ml.to_primitive(), { media_library.VERSION_FIELD: MediaLibrary.VERSION, MediaLibrary.SONGS_FIELD: [s1.to_primitive()], MediaLibrary.PLAYLIST_FIELD: {"test": [s1.alias]}, } )