def test_create(self): self.repo.insert(Playlist(None, 'the name of the playlist')) self.assertEqual([Playlist(1, 'the name of the playlist')], self.repo.get_all())
def test_update(self): self.repo.insert(Playlist(1, 'the name of the playlist')) self.repo.update(Playlist(1, 'the new name of the playlist')) self.assertEqual([Playlist(1, 'the new name of the playlist')], self.repo.get_all())
def test_get_all_the_playlists(self): self.repo.insert(Playlist(1, 'the name of the playlist')) self.repo.insert(Playlist(2, 'the name of another playlist')) self.assertEqual([Playlist(1, 'the name of the playlist'), Playlist(2, 'the name of another playlist')], self.repo.get_all())
def test_delete(self): self.repo.insert(Playlist(1, 'the name of the playlist')) self.repo.delete(1) self.assertEqual([], self.repo.get_all())
with open(filename, encoding="cp1251") as f: i = 0 for row in f: i += 1 if i > 3: num_hour_txt = row[0:2] track_txt = row[6:37] artist_txt = row[38:69] lenght_txt = row[70:75] if lenght_txt != "=====": start_txt = row[79:87] if start_txt != " ": end_txt = row[88:96] '''a = [] a.append(num_hour) a.append(track) a.append(artist) a.append(lenght) a.append(start) a.append(end)''' m = Playlist(date=datefromfile, num_hour=num_hour_txt, track=track_txt, artist=artist_txt, lenght=lenght_txt, start=start_txt, end=end_txt) m.save()
def insert(self, playlist): self.counter = max(self.counter + 1, playlist.id or 0) self.storage[self.counter] = Playlist(self.counter, playlist.name)
def update(self, playlist_id, data): self._validate(data) playlist = Playlist(playlist_id, data['name']) self.playlist_repository.update(playlist)
def add(self, data): self._validate(data) playlist = Playlist(None, data['name']) self.playlist_repository.insert(playlist)
def test_missing_playlist(self): playlist_repository = InMemoryPlaylistRepository({10: Playlist(10, 'name')}) usecase = PlaylistsVideosUsecases(playlist_repository, None, None) self.assertRaises(MissingPlaylist, lambda : usecase.get_all(-1))