-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4080425
commit 1968f3e
Showing
16 changed files
with
119 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
from random import choice | ||
|
||
|
||
_LOWERCASE = [*'qwertyuiopasdfghjklzxcvbnm'] | ||
_UPPER = list(map(lambda x: x.upper(), _LOWERCASE)) | ||
_LETTERS = _LOWERCASE + _UPPER | ||
_PREFIX = 'TEST_' | ||
|
||
|
||
def random_string(length: int) -> str: | ||
result = _PREFIX | ||
for _ in range(length - len(_PREFIX)): | ||
result += choice(_LETTERS) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from unittest import TestCase, main as test_main | ||
|
||
from yt_api.database import Playlist | ||
from yt_api.tests.core import random_string | ||
|
||
|
||
class TestPlaylist(TestCase): | ||
def setUp(self) -> None: | ||
self.spotify_id = random_string(22) | ||
self.youtoube_id = random_string(34) | ||
|
||
def test_add_and_get_playlist(self) -> None: | ||
Playlist.add_playlist( | ||
spotify_id=self.spotify_id, | ||
youtube_id=self.youtoube_id | ||
) | ||
playlist_by_spotify = Playlist.get_playlist(spotify_id=self.spotify_id) | ||
self.assertEqual(playlist_by_spotify.spotify_id, self.spotify_id) | ||
self.assertEqual(playlist_by_spotify.youtube_id, self.youtoube_id) | ||
playlist_by_youtube = Playlist.get_playlist(youtube_id=self.youtoube_id) | ||
self.assertEqual(playlist_by_youtube.spotify_id, self.spotify_id) | ||
self.assertEqual(playlist_by_youtube.youtube_id, self.youtoube_id) | ||
|
||
def test_remove_playlist(self) -> None: | ||
Playlist.add_playlist( | ||
spotify_id=self.spotify_id, | ||
youtube_id=self.youtoube_id | ||
) | ||
Playlist.remove_playlist(spotify_id=self.spotify_id) | ||
playlist = Playlist.get_playlist(spotify_id=self.spotify_id) | ||
self.assertIsNone(playlist) | ||
|
||
|
||
if __name__ == '__main__': | ||
test_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
from unittest import TestCase, main as test_main | ||
|
||
from yt_api.database import Track | ||
from yt_api.tests.core import random_string | ||
|
||
|
||
class TestTrack(TestCase): | ||
def setUp(self) -> None: | ||
self.spotify_id = random_string(22) | ||
self.youtoube_id = random_string(11) | ||
|
||
def test_add_and_get_track(self) -> None: | ||
Track.add_track( | ||
spotify_id=self.spotify_id, | ||
youtube_id=self.youtoube_id | ||
) | ||
track_by_spotify = Track.get_track(spotify_id=self.spotify_id) | ||
self.assertEqual(track_by_spotify.spotify_id, self.spotify_id) | ||
self.assertEqual(track_by_spotify.youtube_id, self.youtoube_id) | ||
track_by_youtube = Track.get_track(youtube_id=self.youtoube_id) | ||
self.assertEqual(track_by_youtube.spotify_id, self.spotify_id) | ||
self.assertEqual(track_by_youtube.youtube_id, self.youtoube_id) | ||
|
||
def test_remove_track(self) -> None: | ||
Track.add_track( | ||
spotify_id=self.spotify_id, | ||
youtube_id=self.youtoube_id | ||
) | ||
Track.remove_track(spotify_id=self.spotify_id) | ||
track = Track.get_track(spotify_id=self.spotify_id) | ||
self.assertIsNone(track) | ||
|
||
|
||
if __name__ == '__main__': | ||
test_main() |