mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Adding Deezer Module and Deezer Tests
This commit is contained in:
@@ -19,3 +19,10 @@ class TestsConstants(Singleton):
|
||||
self.SPOTIFY_ALBUM_URL = 'https://open.spotify.com/album/71O60S5gIJSIAhdnrDIh3N'
|
||||
self.SPOTIFY_WRONG1_URL = 'https://open.spotify.com/wrongUrl'
|
||||
self.SPOTIFY_WRONG2_URL = 'https://open.spotify.com/track/WrongID'
|
||||
|
||||
self.DEEZER_TRACK_URL = 'https://www.deezer.com/br/track/33560861'
|
||||
self.DEEZER_ARTIST_URL = 'https://www.deezer.com/br/artist/180'
|
||||
self.DEEZER_PLAYLIST_URL = 'https://www.deezer.com/br/playlist/1001939451'
|
||||
self.DEEZER_ALBUM_URL = 'https://www.deezer.com/en/album/236107012'
|
||||
self.DEEZER_WRONG1_URL = 'xxxhttps://www.deezer.com/br/album/5'
|
||||
self.DEEZER_WRONG2_URL = 'https://www.deezer.com/en/album/23610701252'
|
||||
|
||||
66
Tests/VDeezerTests.py
Normal file
66
Tests/VDeezerTests.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from Tests.TestBase import VulkanTesterBase
|
||||
from Exceptions.Exceptions import DeezerError
|
||||
|
||||
|
||||
class VulkanDeezerTest(VulkanTesterBase):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def test_deezerTrack(self) -> bool:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_TRACK_URL))
|
||||
|
||||
if len(musics) > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def test_deezerPlaylist(self) -> bool:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_PLAYLIST_URL))
|
||||
|
||||
if len(musics) > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def test_deezerArtist(self) -> bool:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_ARTIST_URL))
|
||||
|
||||
if len(musics) > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def test_deezerAlbum(self) -> bool:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_ALBUM_URL))
|
||||
|
||||
if len(musics) > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def test_deezerWrongUrlShouldThrowException(self) -> bool:
|
||||
try:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_WRONG1_URL))
|
||||
|
||||
except DeezerError as e:
|
||||
print(f'Deezer Error -> {e.message}')
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def test_deezerWrongUrlTwoShouldThrowException(self) -> bool:
|
||||
try:
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.DEEZER_WRONG2_URL))
|
||||
|
||||
except DeezerError as e:
|
||||
print(f'Deezer Error -> {e.message}')
|
||||
return True
|
||||
except Exception as e:
|
||||
return False
|
||||
@@ -58,15 +58,25 @@ class VulkanDownloaderTest(VulkanTesterBase):
|
||||
|
||||
def test_YoutubeMixPlaylist(self) -> None:
|
||||
# Search the link to determine names
|
||||
music = self._runner.run_coroutine(
|
||||
musics = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.YT_MIX_URL))
|
||||
|
||||
# Musics from Mix should download only the first music
|
||||
if len(music) == 1:
|
||||
return True
|
||||
else:
|
||||
if len(musics) != 1:
|
||||
return False
|
||||
|
||||
playlist = Playlist()
|
||||
song = Song(musics[0], playlist, '')
|
||||
playlist.add_song(song)
|
||||
|
||||
self._runner.run_coroutine(self._downloader.download_song(song))
|
||||
|
||||
if song.problematic:
|
||||
return False
|
||||
else:
|
||||
print(song.title)
|
||||
return True
|
||||
|
||||
def test_musicTitle(self):
|
||||
playlist = Playlist()
|
||||
song = Song(self._constants.MUSIC_TITLE_STRING, playlist, '')
|
||||
@@ -81,11 +91,30 @@ class VulkanDownloaderTest(VulkanTesterBase):
|
||||
return True
|
||||
|
||||
def test_YoutubePersonalPlaylist(self) -> None:
|
||||
musics = self._runner.run_coroutine(
|
||||
musicsList = self._runner.run_coroutine(
|
||||
self._searcher.search(self._constants.YT_PERSONAL_PLAYLIST_URL))
|
||||
|
||||
if len(musics) > 0:
|
||||
print(musics)
|
||||
return True
|
||||
else:
|
||||
if len(musicsList) == 0:
|
||||
return False
|
||||
|
||||
# Create and store songs in list
|
||||
playlist = Playlist()
|
||||
songsList: List[Song] = []
|
||||
for info in musicsList:
|
||||
song = Song(identifier=info, playlist=playlist, requester='')
|
||||
playlist.add_song(song)
|
||||
songsList.append(song)
|
||||
|
||||
# Create a list of coroutines without waiting for them
|
||||
tasks: List[Task] = []
|
||||
for song in songsList:
|
||||
tasks.append(self._downloader.download_song(song))
|
||||
|
||||
# Send for runner to execute them concurrently
|
||||
self._runner.run_coroutines_list(tasks)
|
||||
|
||||
for song in songsList:
|
||||
if not song.problematic and song.title == None:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user