Rename with_ to copy

This commit is contained in:
Thomas Adamcik 2010-11-01 00:56:06 +01:00
parent 2c117e8f15
commit 913bac3b0d
4 changed files with 7 additions and 7 deletions

View File

@ -93,7 +93,7 @@ class DummyStoredPlaylistsController(BaseStoredPlaylistsController):
def rename(self, playlist, new_name):
self._playlists[self._playlists.index(playlist)] = \
playlist.with_(name=new_name)
playlist.copy(name=new_name)
def save(self, playlist):
self._playlists.append(playlist)

View File

@ -116,7 +116,7 @@ class LocalStoredPlaylistsController(BaseStoredPlaylistsController):
src = os.path.join(self._folder, playlist.name + '.m3u')
dst = os.path.join(self._folder, name + '.m3u')
renamed = playlist.with_(name=name)
renamed = playlist.copy(name=name)
index = self._playlists.index(playlist)
self._playlists[index] = renamed

View File

@ -179,7 +179,7 @@ class Playlist(ImmutableObject):
def mpd_format(self, *args, **kwargs):
return translator.playlist_to_mpd_format(self, *args, **kwargs)
def with_(self, uri=None, name=None, tracks=None, last_modified=None):
def copy(self, uri=None, name=None, tracks=None, last_modified=None):
"""
Create a new playlist object with the given values. The values that are
not given are taken from the object the method is called on.

View File

@ -398,7 +398,7 @@ class PlaylistTest(unittest.TestCase):
last_modified = dt.datetime.now()
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.with_(uri=u'another uri')
new_playlist = playlist.copy(uri=u'another uri')
self.assertEqual(new_playlist.uri, u'another uri')
self.assertEqual(new_playlist.name, u'a name')
self.assertEqual(new_playlist.tracks, tracks)
@ -409,7 +409,7 @@ class PlaylistTest(unittest.TestCase):
last_modified = dt.datetime.now()
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.with_(name=u'another name')
new_playlist = playlist.copy(name=u'another name')
self.assertEqual(new_playlist.uri, u'an uri')
self.assertEqual(new_playlist.name, u'another name')
self.assertEqual(new_playlist.tracks, tracks)
@ -421,7 +421,7 @@ class PlaylistTest(unittest.TestCase):
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_tracks = [Track(), Track()]
new_playlist = playlist.with_(tracks=new_tracks)
new_playlist = playlist.copy(tracks=new_tracks)
self.assertEqual(new_playlist.uri, u'an uri')
self.assertEqual(new_playlist.name, u'a name')
self.assertEqual(new_playlist.tracks, new_tracks)
@ -433,7 +433,7 @@ class PlaylistTest(unittest.TestCase):
new_last_modified = last_modified + dt.timedelta(1)
playlist = Playlist(uri=u'an uri', name=u'a name', tracks=tracks,
last_modified=last_modified)
new_playlist = playlist.with_(last_modified=new_last_modified)
new_playlist = playlist.copy(last_modified=new_last_modified)
self.assertEqual(new_playlist.uri, u'an uri')
self.assertEqual(new_playlist.name, u'a name')
self.assertEqual(new_playlist.tracks, tracks)