# Path: rock/constants.py
# MOUNT_PATH = os.environ.get('ROCK_MOUNT_PATH', '/')
# RUNTIMES = ['node', 'perl', 'php', 'python', 'ruby']
# SHELL = (os.environ.get('ROCK_SHELL') or '/bin/bash -c').split()
# 
# Path: rock/utils.py
# def isexecutable(path):
#     def isstr(s):
#     def isstr(s):
# def raw(text):
#     def __init__(self):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def run(self):
#     def write(self, text):
# class Shell(object):
# 
# Path: rock/exceptions.py
# class ConfigError(Error):
#     pass


import helper
import uuid
from rock import constants, utils
from rock.exceptions import ConfigError
from __future__ import unicode_literals



class UtilsTestCase(helper.unittest.TestCase):

    def test_shell(self):
        utils.Shell.run = lambda self: self
        s = utils.Shell()
        self.assertTrue(isinstance(s.__enter__(), utils.Shell))
        s.write('ok')
        s.__exit__(None, None, None)
        self.assertEqual(s.stdin.getvalue(), 'ok\n')
        def execl(*args):
            self.assertEqual(len(args), 4)
            self.assertEqual(args[0], '/bin/bash')
            self.assertEqual(args[1], '-l')
            self.assertEqual(args[2], '-c')
            self.assertEqual(args[3], 'ok\n')
        utils.os.execl = execl
        s.__exit__('type', 'value', 'tracebook')

    def test_noshell(self):
        previous_shell = constants.SHELL
        try:
            name = '%s' % uuid.uuid4()

# Path: rock/constants.py
# MOUNT_PATH = os.environ.get('ROCK_MOUNT_PATH', '/')
# RUNTIMES = ['node', 'perl', 'php', 'python', 'ruby']
# SHELL = (os.environ.get('ROCK_SHELL') or '/bin/bash -c').split()
# 
# Path: rock/utils.py
# def isexecutable(path):
#     def isstr(s):
#     def isstr(s):
# def raw(text):
#     def __init__(self):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
#     def run(self):
#     def write(self, text):
# class Shell(object):
# 
# Path: rock/exceptions.py
# class ConfigError(Error):
#     pass


# Path: tests/test_utils.py
import helper
import uuid
from rock import constants, utils
from rock.exceptions import ConfigError

from __future__ import unicode_literals



class UtilsTestCase(helper.unittest.TestCase):

    def test_shell(self):
        utils.Shell.run = lambda self: self
        s = utils.Shell()
        self.assertTrue(isinstance(s.__enter__(), utils.Shell))
        s.write('ok')
        s.__exit__(None, None, None)
        self.assertEqual(s.stdin.getvalue(), 'ok\n')
        def execl(*args):
            self.assertEqual(len(args), 4)
            self.assertEqual(args[0], '/bin/bash')
            self.assertEqual(args[1], '-l')
            self.assertEqual(args[2], '-c')
            self.assertEqual(args[3], 'ok\n')
        utils.os.execl = execl
        s.__exit__('type', 'value', 'tracebook')

    def test_noshell(self):
        previous_shell = constants.SHELL
        try:
            name = '%s' % uuid.uuid4()

            constants.SHELL = ['/bin/%s' % name, name]