Skip to content

Commit

Permalink
Test: 8 More Tests Added
Browse files Browse the repository at this point in the history
  • Loading branch information
faridrasidov committed Jul 23, 2024
1 parent c42e28e commit c821253
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from soundcld.resource.playlist_album import AlbumPlaylist, BasicAlbumPlaylist
from soundcld.resource.webprofiles import WebProfile
from soundcld.resource.aliases import SearchItem
from soundcld.resource.comments import BasicComment, Comment
22 changes: 22 additions & 0 deletions tests/test_api_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from soundcld.api_handler import SoundCloud
from data_types import *

@pytest.fixture
def soundcloud_client():
prompt = 'witch house'
client = SoundCloud()
return client, prompt

def test_get_track_by_tag(soundcloud_client):
client, prompt = soundcloud_client
all_tagged_tracks = client.get_track_by_tag(prompt)
i = 0
for track in all_tagged_tracks:
if i > 20:
break
i += 1
assert isinstance(track, BasicTrack)

if __name__ == '__main__':
pytest.main()
29 changes: 29 additions & 0 deletions tests/test_api_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def soundcloud_client():
client = SoundCloud()
return client, track_id

def test_get_track(soundcloud_client):
client, track_id = soundcloud_client
track = client.get_track(track_id)
assert isinstance(track, BasicTrack)

def test_get_track_liker(soundcloud_client):
client, track_id = soundcloud_client
track_liker = client.get_track_liker(track_id)
Expand All @@ -20,5 +25,29 @@ def test_get_track_reposter(soundcloud_client):
for user in track_reposter:
assert isinstance(user, (User, BasicUser))

def test_get_albums_with_track(soundcloud_client):
client, track_id = soundcloud_client
track_added_albums = client.get_albums_with_track(track_id)
for album in track_added_albums:
assert isinstance(album, (AlbumPlaylist, BasicAlbumPlaylist))

def test_get_playlist_with_track(soundcloud_client):
client, track_id = soundcloud_client
track_added_playlists = client.get_playlists_with_track(track_id)
for playlist in track_added_playlists:
assert isinstance(playlist, (AlbumPlaylist, BasicAlbumPlaylist))

def test_get_track_comments(soundcloud_client):
client, track_id = soundcloud_client
comments = client.get_track_comments(track_id)
for comment in comments:
assert isinstance(comment, BasicComment)

def test_get_related_tracks(soundcloud_client):
client, track_id = soundcloud_client
related_tracks = client.get_related_tracks(track_id)
for track in related_tracks:
assert isinstance(track, BasicTrack)

if __name__ == '__main__':
pytest.main()
10 changes: 10 additions & 0 deletions tests/test_api_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def soundcloud_client():
client = SoundCloud()
return client, user_id

def test_get_user(soundcloud_client):
client, user_id = soundcloud_client
user = client.get_user(user_id)
assert isinstance(user, User)

def test_get_user_tracks(soundcloud_client):
client, user_id = soundcloud_client
user_tracks = client.get_user_tracks(user_id)
Expand Down Expand Up @@ -50,5 +55,10 @@ def test_get_user_followings(soundcloud_client):
for user in followings:
assert isinstance(user, (User, BasicUser))

def test_get_user_comments(soundcloud_client):
client, user_id = soundcloud_client
comments = client.get_user_comments(user_id)
for comment in comments:
assert isinstance(comment, Comment)
if __name__ == '__main__':
pytest.main()

0 comments on commit c821253

Please sign in to comment.