# Path: spec/ui/_fixture.py
# def update_environment(_):
#     _.bad_expression = '?'
#     _.expression = 'richard stallman'
# 
#     _.env_path = '/tmp/testing-sandbox'
#     _.env = TestFileEnvironment(_.env_path)
# 
#     _.fixtures = 'fixtures'
#     _.fixtures_path = '/tmp/ipodio_fixtures'
# 
#     if not os.path.isdir(_.fixtures_path):
#         shutil.copytree(_.fixtures, _.fixtures_path)
# 
#     _.songs = ['fixtures/song1.mp3', 'fixtures/song2.mp3']
#     _.song_paths = [os.path.abspath(song) for song in _.songs]
# 
#     _.mountpoint = 'ipod'
#     _.mountpoint_path = os.path.join(_.env_path, _.mountpoint)
#     _.cmd = ['ipodio', '--mount', _.mountpoint]


from expects import expect
from mamba import describe, context, before, after
from spec.ui._ipod_helpers import *
from spec.ui._fixture import update_environment
# -*- coding: utf-8 -*-




with describe('ipodio playlist add') as _:
    @before.all
    def setup_all():
        _.playlist_name = 'playlist'
        update_environment(_)
        bootstrap_ipod(_.mountpoint_path)
        populate_ipod(_.mountpoint_path, _.songs)

    with context('without a name'):
        def should_print_an_error():
            execution = _.env.run(*_.cmd + ['playlist', 'add'], expect_error=True)

            expect(execution.stderr).to.have('Usage:')

    with context('given a name which is not an existing playlist'):
        def should_print_an_error_():
            execution = _.env.run(*_.cmd + ['playlist', 'add', 'foo', _.expression])

            expect(execution.stdout).to.have('The playlist "foo" does not exist')

    with context('given a name'):
        with context('but not an expression'):
            def should_print_an_error__():

# Path: spec/ui/_fixture.py
# def update_environment(_):
#     _.bad_expression = '?'
#     _.expression = 'richard stallman'
# 
#     _.env_path = '/tmp/testing-sandbox'
#     _.env = TestFileEnvironment(_.env_path)
# 
#     _.fixtures = 'fixtures'
#     _.fixtures_path = '/tmp/ipodio_fixtures'
# 
#     if not os.path.isdir(_.fixtures_path):
#         shutil.copytree(_.fixtures, _.fixtures_path)
# 
#     _.songs = ['fixtures/song1.mp3', 'fixtures/song2.mp3']
#     _.song_paths = [os.path.abspath(song) for song in _.songs]
# 
#     _.mountpoint = 'ipod'
#     _.mountpoint_path = os.path.join(_.env_path, _.mountpoint)
#     _.cmd = ['ipodio', '--mount', _.mountpoint]


# Path: spec/ui/playlist_add_spec.py
from expects import expect
from mamba import describe, context, before, after
from spec.ui._ipod_helpers import *
from spec.ui._fixture import update_environment

# -*- coding: utf-8 -*-




with describe('ipodio playlist add') as _:
    @before.all
    def setup_all():
        _.playlist_name = 'playlist'
        update_environment(_)
        bootstrap_ipod(_.mountpoint_path)
        populate_ipod(_.mountpoint_path, _.songs)

    with context('without a name'):
        def should_print_an_error():
            execution = _.env.run(*_.cmd + ['playlist', 'add'], expect_error=True)

            expect(execution.stderr).to.have('Usage:')

    with context('given a name which is not an existing playlist'):
        def should_print_an_error_():
            execution = _.env.run(*_.cmd + ['playlist', 'add', 'foo', _.expression])

            expect(execution.stdout).to.have('The playlist "foo" does not exist')

    with context('given a name'):
        with context('but not an expression'):
            def should_print_an_error__():

                execution = _.env.run(*_.cmd + ['playlist', 'add', _.playlist_name], expect_error=True)