예제 #1
0
def test_get_album_list_filter_by_favorite():
    params = {"favorite": True}
    rq_album.add_favorite(env.env_var.get("USER_1_TOKEN"),
                          env.env_var["ALBUM_ID_4"])
    list_albums = rq_album.get_list(token=env.env_var.get("USER_1_TOKEN"),
                                    params=params,
                                    count=1)
    assert list_albums[0]["album_id"] == env.env_var['ALBUM_ID_4']
def test_add_album_to_favorites():
    rq_album.delete_all(token=env.env_var['USER_1_TOKEN'],
                        user_id=env.env_var['USER_1_MAIL'])
    album = rq_album.create(token=env.env_var['USER_1_TOKEN'],
                            data={"name": "new album favorite"})
    env.env_var["ALBUM_ID_1"] = album["album_id"]
    rq_album.add_favorite(env.env_var.get("USER_1_TOKEN"),
                          env.env_var["ALBUM_ID_1"])
    list_albums = rq_album.get_list(token=env.env_var.get("USER_1_TOKEN"),
                                    params={},
                                    count=1)
    assert list_albums[0]["album_id"] == env.env_var['ALBUM_ID_1']
    assert list_albums[0]['is_favorite'] == True
def test_remove_album_to_favorites():
    album = rq_album.create(token=env.env_var['USER_1_TOKEN'],
                            data={"name": "new album remove favorite"})
    env.env_var["ALBUM_ID_2"] = album["album_id"]
    #add and remove
    rq_album.add_favorite(env.env_var.get("USER_1_TOKEN"),
                          env.env_var["ALBUM_ID_2"])
    rq_album.remove_favorite(env.env_var.get("USER_1_TOKEN"),
                             env.env_var["ALBUM_ID_2"])
    list_albums = rq_album.get_list(token=env.env_var.get("USER_1_TOKEN"),
                                    params={},
                                    count=2)
    assert list_albums[0]["album_id"] == env.env_var['ALBUM_ID_2']
    assert list_albums[0]['is_favorite'] == False
    assert list_albums[1]["album_id"] == env.env_var['ALBUM_ID_1']
    assert list_albums[1]['is_favorite'] == True
def test_add_bad_album_in_favorites():
    rq_album.add_favorite(env.env_var.get("USER_1_TOKEN"),
                          "1",
                          status_code=404)
def test_a_not_member_user_try_to_add_to_favorites():
    rq_album.add_favorite(env.env_var.get("USER_2_TOKEN"),
                          env.env_var['ALBUM_ID_1'],
                          status_code=404)