def test_add_to_playlist_nonexistent_playlist_nonexistent_video(capfd):
    player = VideoPlayer()
    player.add_to_playlist("another_playlist", "does_not_exist_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot add video to another_playlist: Playlist does not exist" in lines[0]
def test_add_to_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_COOL_playlist")
    player.add_to_playlist("my_cool_PLAYLIST", "amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 2
    assert "Successfully created new playlist: my_COOL_playlist" in lines[0]
    assert "Added video to my_cool_PLAYLIST: Amazing Cats" in lines[1]
def test_add_to_playlist_nonexistent_video(capfd):
    player = VideoPlayer()
    player.create_playlist("my_cool_playlist")
    player.add_to_playlist("my_cool_playlist", "amazing_cats_video_id")
    player.add_to_playlist("my_cool_playlist", "some_other_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 3
    assert "Successfully created new playlist: my_cool_playlist" in lines[0]
    assert "Added video to my_cool_playlist: Amazing Cats" in lines[1]
    assert "Cannot add video to my_cool_playlist: Video does not exist" in lines[2]
Exemplo n.º 4
0
def test_flag_video_add_to_playlist(capfd):
    player = VideoPlayer()
    player.flag_video("amazing_cats_video_id")
    player.create_playlist("my_playlist")
    player.add_to_playlist("my_playlist", "amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 3
    assert ("Successfully flagged video: Amazing Cats "
            "(reason: Not supplied)") in lines[0]
    assert "Successfully created new playlist: my_playlist" in lines[1]
    assert ("Cannot add video to my_playlist: Video is currently "
            "flagged (reason: Not supplied)") in lines[2]
def test_remove_from_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_cool_playlist")
    player.add_to_playlist("my_cool_playlist", "amazing_cats_video_id")
    player.remove_from_playlist("my_COOL_playlist", "amazing_cats_video_id")
    player.remove_from_playlist("my_cool_playlist", "amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 4
    assert "Successfully created new playlist: my_cool_playlist" in lines[0]
    assert "Added video to my_cool_playlist: Amazing Cats" in lines[1]
    assert "Removed video from my_COOL_playlist: Amazing Cats" in lines[2]
    assert "Cannot remove video from my_cool_playlist: Video is not in playlist" in lines[3]
def test_show_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_cool_playlist")
    player.show_playlist("my_cool_playlist")
    player.add_to_playlist("my_cool_playlist", "amazing_cats_video_id")
    player.show_playlist("my_COOL_playlist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 6
    assert "Successfully created new playlist: my_cool_playlist" in lines[0]
    assert "Showing playlist: my_cool_playlist" in lines[1]
    assert "No videos here yet" in lines[2]
    assert "Added video to my_cool_playlist: Amazing Cats" in lines[3]
    assert "Showing playlist: my_COOL_playlist" in lines[4]
    assert "Amazing Cats (amazing_cats_video_id) [#cat #animal]" in lines[5]
Exemplo n.º 7
0
def test_flag_video_show_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_playlist")
    player.add_to_playlist("my_playlist", "amazing_cats_video_id")
    player.flag_video("amazing_cats_video_id", "dont_like_cats")
    player.show_playlist("my_playlist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 5
    assert "Successfully created new playlist: my_playlist" in lines[0]
    assert "Added video to my_playlist: Amazing Cats" in lines[1]
    assert "Successfully flagged video: Amazing Cats " \
           "(reason: dont_like_cats)" in lines[2]
    assert "Showing playlist: my_playlist" in lines[3]
    assert ("Amazing Cats (amazing_cats_video_id) [#cat #animal] - FLAGGED "
            "(reason: dont_like_cats)") in lines[4]
def test_remove_from_playlist_then_re_add(capfd):
    player = VideoPlayer()
    player.create_playlist("MY_playlist")
    player.add_to_playlist("my_playlist", "amazing_cats_video_id")
    player.add_to_playlist("my_playlist", "life_at_google_video_id")
    player.remove_from_playlist("my_playlist", "amazing_cats_video_id")
    player.add_to_playlist("my_playlist", "amazing_cats_video_id")
    player.show_playlist("my_playLIST")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 8
    assert "Showing playlist: my_playLIST" in lines[5]
    assert "Life at Google (life_at_google_video_id) [#google #career]" in lines[6]
    assert "Amazing Cats (amazing_cats_video_id) [#cat #animal]" in lines[7]