def test_next_seq():
    """Playlist.next() returns the next track in sequential mode
    """
    sample = "\n".join(["/first/file", "/second/file"])
    with patch.object(builtins, 'open',
                      mock_open(read_data=sample)) as mock_file:
        # see
        # http://bash-shell.net/blog/2014/feb/27/file-iteration-python-mock/
        # Apparently this is patched in python 3...
        mock_file.return_value.__iter__.return_value = sample.splitlines()
        playlist = Playlist('seq')
        playlist.load('bogus')
    eq_(playlist.next_track(), '/second/file')
    eq_(playlist.next_track(), '/first/file')
def test_prepend_basepath():
    """Loading a relative path playlist entry prepends the basepath
    """
    sample = StringIO("actual/entry")
    actual = Playlist.parse_playlist(sample, '/basepath/')
    expected = ['/basepath/actual/entry']
    eq_(actual, expected)
def test_absolute_path():
    """"Loading an absolute path playlist entry doesn't use the basepath
    """
    sample = StringIO("/actual/entry")
    actual = Playlist.parse_playlist(sample, '/basepath/')
    expected = ['/actual/entry']
    eq_(actual, expected)
def test_ignore_comments():
    """Loading a playlist ignores comment lines
    """
    sample = StringIO("\n".join([
        "#ignore this",
        "/actual/entry"]))
    actual = Playlist.parse_playlist(sample, '')
    expected = ['/actual/entry']
    eq_(actual, expected)