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_create_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_PLAYlist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Successfully created new playlist: my_PLAYlist" in lines[0]
def test_search_videos_no_results(capfd):
    player = VideoPlayer()
    player.search_videos("blah")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "No search results for blah" in lines[0]
def test_delete_playlist_nonexistent(capfd):
    player = VideoPlayer()
    player.delete_playlist("my_cool_playlist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot delete playlist my_cool_playlist: Playlist does not exist" in lines[0]
def test_remove_from_playlist_nonexistent_playlist(capfd):
    player = VideoPlayer()
    player.remove_from_playlist("my_cool_playlist", "amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot remove video from my_cool_playlist: Playlist does not exist" in lines[0]
def test_show_playlist_nonexistent_playlist(capfd):
    player = VideoPlayer()
    player.show_playlist("another_playlist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot show playlist another_playlist: Playlist does not exist" in lines[0]
def test_show_all_playlists_no_playlists_exist(capfd):
    player = VideoPlayer()
    player.show_all_playlists()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "No playlists exist yet" in lines[0]
def test_stop_video_none_playing(capfd):
    player = VideoPlayer()
    player.stop_video()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot stop video: No video is currently playing" in out
def test_play_video(capfd):
    player = VideoPlayer()
    player.play_video("amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Playing video: Amazing Cats" in out
def test_show_nothing_playing(capfd):
    player = VideoPlayer()
    player.show_playing()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "No video is currently playing" in lines[0]
Example #11
0
def test_flag_video_nonexistent(capfd):
    player = VideoPlayer()
    player.flag_video("video_does_not_exist", "flag_video_reason")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot flag video: Video does not exist" in lines[0]
Example #12
0
def test_allow_video_nonexistent(capfd):
    player = VideoPlayer()
    player.allow_video("video_does_not_exist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot remove flag from video: Video does not exist" in lines[0]
def test_play_video_nonexistent(capfd):
    player = VideoPlayer()
    player.play_video("does_not_exist")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot play video: Video does not exist" in out
Example #14
0
def test_allow_video_not_flagged(capfd):
    player = VideoPlayer()
    player.allow_video("amazing_cats_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot remove flag from video: Video is not flagged" in lines[0]
def test_continue_none_playing(capfd):
    player = VideoPlayer()
    player.continue_video()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Cannot continue video: No video is currently playing" in lines[0]
Example #16
0
def test_flag_video_with_reason(capfd):
    player = VideoPlayer()
    player.flag_video("amazing_cats_video_id", "dont_like_cats")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Successfully flagged video: Amazing Cats (reason: dont_like_cats)" \
           in lines[0]
Example #17
0
def test_flag_video_without_reason(capfd):
    player = VideoPlayer()
    player.flag_video("another_cat_video_id")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert "Successfully flagged video: Another Cat Video " \
           "(reason: Not supplied)" in lines[0]
Example #18
0
 def __init__(self, camera_0=None, camera_1=None):
     super().__init__()
     layout = widgets.QGridLayout()
     self.player_0 = VideoPlayer(camera_0)
     layout.addWidget(self.player_0, 0, 0)
     self.player_1 = VideoPlayer(camera_1)
     layout.addWidget(self.player_1, 0, 1)
     self.setLayout(layout)
def test_play_random_video(capfd):
    player = VideoPlayer()
    player.play_random_video()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert re.match(
        "Playing video: (Amazing Cats|Another Cat Video|Funny Dogs|Life at Google|Video about nothing)",
        out)
def test_create_existing_playlist(capfd):
    player = VideoPlayer()
    player.create_playlist("my_cool_playlist")
    player.create_playlist("my_COOL_PLAYLIST")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 2
    assert "Successfully created new playlist: my_cool_playlist" in lines[0]
    assert ("Cannot create playlist: A playlist with the same name already "
            "exists") in lines[1]
Example #21
0
def test_flag_video_already_flagged(capfd):
    player = VideoPlayer()
    player.flag_video("amazing_cats_video_id", "dont_like_cats")
    player.flag_video("amazing_cats_video_id", "dont_like_cats")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 2
    assert "Successfully flagged video: Amazing Cats (reason: dont_like_cats)" in \
           lines[0]
    assert "Cannot flag video: Video is already flagged" in lines[1]
def test_show_all_videos(capfd):
    player = VideoPlayer()
    player.show_all_videos()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 6
    assert "Here's a list of all available videos:" in lines[0]
    assert "Amazing Cats (amazing_cats_video_id) [#cat #animal]" in lines[1]
    assert "Another Cat Video (another_cat_video_id) [#cat #animal]" in lines[
        2]
    assert "Funny Dogs (funny_dogs_video_id) [#dog #animal]" in lines[3]
    assert "Life at Google (life_at_google_video_id) [#google #career]" in lines[
        4]
    assert "Video about nothing (nothing_video_id) []" in lines[5]
def test_search_videos_with_tag_no_answer(capfd):
    player = VideoPlayer()
    player.search_videos_tag("#cat")
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 5
    assert "Here are the results for #cat:" in lines[0]
    assert "1) Amazing Cats (amazing_cats_video_id) [#cat #animal]" in lines[1]
    assert "2) Another Cat Video (another_cat_video_id) [#cat #animal]" in lines[
        2]
    assert ("Would you like to play any of the above? If yes, "
            "specify the number of the video.") in lines[3]
    assert ("If your answer is not a valid number, we will assume "
            "it's a no.") in lines[4]
Example #24
0
def test_flag_video_stops_paused_video(capfd):
    player = VideoPlayer()
    player.play_video("amazing_cats_video_id")
    player.pause_video()
    player.flag_video("amazing_cats_video_id", "dont_like_cats")
    player.show_playing()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 5
    assert "Playing video: Amazing Cats" in lines[0]
    assert "Pausing video: Amazing Cats" in lines[1]
    assert "Stopping video: Amazing Cats" in lines[2]
    assert "Successfully flagged video: Amazing Cats " \
           "(reason: dont_like_cats)" in lines[3]
    assert "No video is currently playing" in lines[4]
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]
Example #26
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_pause_video_play_video(capfd):
    player = VideoPlayer()
    player.play_video("amazing_cats_video_id")
    player.pause_video()
    player.play_video("amazing_cats_video_id")
    player.show_playing()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 5
    assert "Playing video: Amazing Cats" in lines[0]
    assert "Pausing video: Amazing Cats" in lines[1]
    assert "Stopping video: Amazing Cats" in lines[2]
    assert "Playing video: Amazing Cats" in lines[3]
    assert "Currently playing: Amazing Cats (amazing_cats_video_id) " \
           "[#cat #animal]" in lines[4]
    assert "PAUSED" not in lines[4]
def test_pause_video_show_playing(capfd):
    player = VideoPlayer()
    player.play_video("amazing_cats_video_id")
    player.pause_video()
    player.show_playing()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 3
    assert "Currently playing: Amazing Cats (amazing_cats_video_id) " \
           "[#cat #animal] - PAUSED" in lines[2]
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]
def test_continue_video(capfd):
    player = VideoPlayer()
    player.play_video("amazing_cats_video_id")
    player.pause_video()
    player.continue_video()
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 3
    assert "Playing video: Amazing Cats" in lines[0]
    assert "Pausing video: Amazing Cats" in lines[1]
    assert "Continuing video: Amazing Cats" in lines[2]