def test_list_playlist(self): """test the 'list_playlist'-method of the playlist_handler.py.""" resultlist = list_playlist(self.test_directory) self.assertEqual(resultlist.count('Test_Playlist_1'), 1) self.assertEqual(resultlist.count('Test_Playlist_3'), 1) self.assertEqual(resultlist.count('Test_Playlist_2'), 1) self.remove_files(PLAYLIST_FOLDER)
def setUp(self): """Set up dummy library data.""" super(FlaskTestPlaylistCase, self).setUp() app.config['lib'] = self.lib # Add 2 Items at the beets-database self.lib.add(Item(title='title', path='', id=1)) self.lib.add(Item(title='another title', path='', id=2)) self.test_directory = os.path.abspath('playlist_folder') # Check whether the folder exists list_playlist(PLAYLIST_FOLDER) # Add the needed Playlists. add_playlist(self.test_directory, 'Test_Playlist_1') add_playlist(self.test_directory, 'Test_Playlist_2') add_playlist(self.test_directory, 'Test_Playlist_3') add_playlist(self.test_directory, 'Test_Playlist_95') add_playlist(self.test_directory, 'Test_Playlist_96') add_playlist(self.test_directory, 'Test_Playlist_97') app.config['TESTING'] = True
def test_delete_playlist(self): """test the 'delete_playlist'-method of the playlist_handler.py.""" tester = app.test_client(self) response = tester.post("/delete_Playlist", data={ 'PlayLID': 'Test_Playlist_96', 'Song': '1' }) resultlist = list_playlist(PLAYLIST_FOLDER) self.assertEqual(resultlist.count('Test_Playlist_96'), 0) self.assertEqual(response.status_code, 200)
def test_rename_playlist(self): """test the 'rename_playlist'-method of the playlist_handler.py.""" tester = app.test_client(self) response = tester.post('/rename_Playlist', data={ 'oldVal': 'Test_Playlist_97', 'newVal': 'Test_Case' }) resultlist = list_playlist(PLAYLIST_FOLDER) self.assertEqual(resultlist.count('Test_Playlist_97'), 0) self.assertEqual(resultlist.count('Test_Case'), 1) self.assertEqual(response.status_code, 200)
def items_length(queries): """Called by starting a search out of the view. The function builds up a dynamic URL with the name of the query at the end. Renders the index.html and is a additional method which is called for the footer. The index.html is not used actively, therefore it's like a Mock-up, which is needed for the footer to get the number of search results. :rtype: rendered html-file :return: index.html """ return render_template('index.html', items=g.lib.items(queries), ListofPlaylist=list_playlist( app.config['PLAYLIST_FOLDER']))
def index(): """Called by the main-page of the application. Renders the index.html as a template and calls several methods for the dynamic input of the main-page. :rtype: rendered HTML-template. :return: index.html :rtype: dynamic input for HTML. :return: items -- The current songs in the beets database. :rtype: List :return: ListofPlaylist -- the current list of playlists """ return render_template('index.html', items=g.lib.items(), ListofPlaylist=list_playlist( app.config['PLAYLIST_FOLDER']))
def playlist(queries): """Called by opening a playlist out of the view. The function builds up a dynamic URL with the name of the Playlist at the end. Renders the index.html and is a additional method which is called for the footer. The index.html is not used actively, therefore it's like a Mock-up, which is needed for the footer to get the currenty number of songs in a playlist. :rtype: rendered html-file :return: index.html """ content_of_playlist = read_songs_of_playlist(PLAYLIST_FOLDER, str(queries[0]), g) return render_template('index.html', items=content_of_playlist, ListofPlaylist=list_playlist( app.config['PLAYLIST_FOLDER']))