Move tests to unittest
This commit is contained in:
parent
d1e2b4066b
commit
cc47ad7473
1 changed files with 30 additions and 35 deletions
|
|
@ -1,49 +1,44 @@
|
|||
import unittest
|
||||
from ytmusicapi.ytmusic import YTMusic
|
||||
|
||||
youtube = YTMusic()
|
||||
youtube_auth = YTMusic('../headers_auth.json')
|
||||
|
||||
|
||||
def get_playlists():
|
||||
playlists = youtube.get_playlists()
|
||||
print(playlists)
|
||||
class TestYTMusic(unittest.TestCase):
|
||||
def test_get_playlists(self):
|
||||
playlists = youtube_auth.get_playlists()
|
||||
self.assertGreater(len(playlists), 0)
|
||||
|
||||
def test_get_foreign_playlist(self):
|
||||
songs = youtube.get_playlist_items("PLw-VjHDlEOgs658kAHR_LAaILBXb-s6Q5")
|
||||
self.assertEqual(len(songs), 200)
|
||||
|
||||
def get_foreign_playlist():
|
||||
songs = youtube.get_playlist_items("PLw-VjHDlEOgs658kAHR_LAaILBXb-s6Q5")
|
||||
assert (len(songs) == 200)
|
||||
def test_get_owned_playlist(self):
|
||||
songs = youtube_auth.get_playlist_items('PLQwVIlKxHM6oCeKLTsUx_w9CmWjHKdg68')
|
||||
self.assertEqual(len(songs), 64)
|
||||
|
||||
def test_get_history(self):
|
||||
songs = youtube_auth.get_history()
|
||||
self.assertGreater(len(songs), 0)
|
||||
|
||||
def get_owned_playlist():
|
||||
songs = youtube_auth.get_playlist_items('PLQwVIlKxHM6oCeKLTsUx_w9CmWjHKdg68')
|
||||
assert (len(songs) == 64)
|
||||
def test_search(self):
|
||||
results = youtube_auth.search("Oasis Wonderwall")
|
||||
self.assertGreater(len(results), 0)
|
||||
|
||||
|
||||
def get_history():
|
||||
songs = youtube_auth.get_history()
|
||||
assert (len(songs) > 0)
|
||||
|
||||
def search():
|
||||
results = youtube_auth.search("Oasis Wonderwall")
|
||||
print(results)
|
||||
|
||||
|
||||
#end to end test adding playlist, adding item, deleting item, deleting playlist
|
||||
def end2end():
|
||||
playlist = youtube_auth.create_playlist("test", "test description")
|
||||
print(playlist)
|
||||
response = youtube_auth.add_playlist_items(playlist,['y0Hhvtmv0gk'])
|
||||
assert(response == 'STATUS_SUCCEEDED')
|
||||
items = youtube_auth.get_playlist_items(playlist)
|
||||
assert(len(items) == 1)
|
||||
response = youtube_auth.remove_playlist_items(playlist, items)
|
||||
assert(response == 'STATUS_SUCCEEDED')
|
||||
response = youtube_auth.delete_playlist(playlist)
|
||||
assert(response['command']['handlePlaylistDeletionCommand']['playlistId'] == playlist)
|
||||
# end to end test adding playlist, adding item, deleting item, deleting playlist
|
||||
def test_end2end(self):
|
||||
playlist = youtube_auth.create_playlist("test", "test description")
|
||||
self.assertEqual(len(playlist), 34, "Playlist creation failed")
|
||||
response = youtube_auth.add_playlist_items(playlist, ['y0Hhvtmv0gk'])
|
||||
self.assertEqual(response, 'STATUS_SUCCEEDED', "Adding playlist item failed")
|
||||
items = youtube_auth.get_playlist_items(playlist)
|
||||
self.assertEqual(len(items), 1, "Getting playlist items failed")
|
||||
response = youtube_auth.remove_playlist_items(playlist, items)
|
||||
self.assertEqual(response, 'STATUS_SUCCEEDED', "Playlist item removal failed")
|
||||
response = youtube_auth.delete_playlist(playlist)
|
||||
self.assertEqual(response['command']['handlePlaylistDeletionCommand']['playlistId'], playlist, "Playlist removal failed")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
end2end()
|
||||
#get_history()
|
||||
#search()
|
||||
#get_owned_playlist()
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue