def test_vote_twice(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"]) r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"]) print(r.text) assert not r.ok
def test_add_playlist_no_password(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r = user_logic.add_playlist( url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_no_password"]) assert not r.ok
def test_change_password_wrong_password(self, get_url, get_tests_data, change_password_test_case): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r = user_logic.change_password( url=urljoin(get_url, "/users/change_password"), json=get_tests_data[change_password_test_case]) assert "error" in r.text
def test_dont_show_password(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r = user_logic.get_user( url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"]) print(r.text) assert "password" not in r.text
def test_add_song_not_exist(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r = playlist_logic.add_song_to_playlist( url=urljoin(get_url, "/playlists/add_song"), json=get_tests_data["add_song_to_playlist"]) print(r.text) assert "error" in r.text
def test_add_playlist_success(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_success"]) r = user_logic.get_user( url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"]) assert get_tests_data["add_playlist_success"][ "playlist_name"] in r.json()["data"]["playlists"]
def test_sign_up_same_id(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r2 = user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name="lironshani") if "error" not in r2.text: r = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) print(r.text) assert "error" in r.text else: assert False
def test_add_song_success(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_success"]) playlist_logic.add_song_to_playlist( url=urljoin(get_url, "/playlists/add_song"), json=get_tests_data["add_song_to_playlist"]) user_logic.get_user(url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"]) assert False #cant see the song in the playlist
def test_add_playlist_twice(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r1 = user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist"]) r = user_logic.get_user( url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"]) if get_tests_data["add_playlist"]["playlist_name"] in r.json( )["data"]["playlists"]: r = user_logic.add_playlist(url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist"]) assert "error" in r.text
def test_change_password_success(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) user_logic.change_password( url=urljoin(get_url, "/users/change_password"), json=get_tests_data["change_password_success"]) user_logic.add_playlist( url=urljoin(get_url, "/users/add_playlist"), json=get_tests_data["add_playlist_new_password"]) r = user_logic.get_user( url=urljoin(get_url, "/users/get_user"), user_name=get_tests_data["new_user"]["user_name"]) print(r.text) assert get_tests_data["add_playlist_new_password"][ "playlist_name"] in r.json()["data"]["playlists"]
def test_add_song_twice(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) r = playlist_logic.add_song_to_playlist( url=urljoin(get_url, "/playlists/add_song"), json=get_tests_data["add_song_to_playlist"]) if r.ok: r = playlist_logic.add_song_to_playlist( url=urljoin(get_url, "/playlists/add_song"), json=get_tests_data["add_song_to_playlist"]) print(r.text) assert "error" in r.text else: assert False
def test_down_vote_wrong_password(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) r = song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_down_vote_wrong_password"]) assert "error" in r.text
def test_up_vote(self, get_url, get_tests_data): user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) song_logic.add_song(url=urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) song_logic.song_up_vote(url=urljoin(get_url, "/songs/upvote"), json=get_tests_data["song_up_vote"]) r = song_logic.get_songs_by_rating_greater(url=urljoin(get_url, "/songs/ranked_songs"), rating=0) assert get_tests_data["add_song_success"]["song_title"] in r.json()["data"]
def test_down_vote_less_0(self, get_url, get_tests_data): r = song_logic.add_song(urljoin(get_url, "/songs/add_song"), json=get_tests_data["add_song_success"]) r1 = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data["new_user"]) r1 = song_logic.song_down_vote(url=urljoin(get_url, "/songs/downvote"), json=get_tests_data["song_down_vote"]) r = song_logic.get_songs_by_rating_less(url=urljoin(get_url, "/songs/ranked_songs"), rating=0) assert r.json()["data"] == []
def test_sign_up(self, get_url, get_tests_data, sign_up_test_case): r = user_logic.add_user(url=urljoin(get_url, "/users/add_user"), json=get_tests_data[sign_up_test_case]) assert not r.ok