def test_try_sudo_tries_to_sudo_if_not_root(self):
        try_sudo()

        self.check_call.assert_called_once_with(
            "sudo echo 'yes we can sudo'",
            shell=True
        )
def create_hypernode_vagrant(directory=None,
                             php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
                             xdebug_enabled=False,
                             skip_try_sudo=False,
                             xenial=False,
                             no_provision=False):
    """
    Create a hypernode-vagrant
    :param str directory: Path to the hypernode-vagrant checkout,
    None for temporary directory
    :param str php_version: The PHP version to use
    :param bool xdebug_enabled: Install xdebug in the vagrant
    :param bool skip_try_sudo: Skip try to sudo beforehand to fail early
    :param bool xenial: Start a Xenial image
    :param bool no_provision: Pass --no-provision to vagrant up
    :return str directory: Path to the hypernode-vagrant checkout
    None for a temp dir that will automatically be created
    """
    if not skip_try_sudo:
        try_sudo()
    clone_path = ensure_directory_for_checkout(directory=directory)
    ensure_hypernode_vagrant_checkout(directory=clone_path)
    ensure_required_plugins_are_installed()
    start_hypernode_vagrant(clone_path,
                            php_version=php_version,
                            xdebug_enabled=xdebug_enabled,
                            xenial=xenial,
                            no_provision=no_provision)
    return clone_path
Exemple #3
0
def create_hypernode_vagrant(directory=None,
                             php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION):
    """
    Create a hypernode-vagrant
    :param str directory: Path to the hypernode-vagrant checkout,
    None for temporary directory
    :param str php_version: The PHP version to use
    :return str directory: Path to the hypernode-vagrant checkout
    None for a temp dir that will automatically be created
    """
    try_sudo()
    clone_path = ensure_directory_for_checkout(directory=directory)
    ensure_hypernode_vagrant_checkout(directory=clone_path)
    ensure_required_plugins_are_installed()
    start_hypernode_vagrant(clone_path, php_version=php_version)
    return clone_path
def create_hypernode_vagrant(directory=None,
                             php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
                             xdebug_enabled=False):
    """
    Create a hypernode-vagrant
    :param str directory: Path to the hypernode-vagrant checkout,
    None for temporary directory
    :param str php_version: The PHP version to use
    :param bool xdebug_enabled: Install xdebug in the vagrant
    :return str directory: Path to the hypernode-vagrant checkout
    None for a temp dir that will automatically be created
    """
    try_sudo()
    clone_path = ensure_directory_for_checkout(directory=directory)
    ensure_hypernode_vagrant_checkout(directory=clone_path)
    ensure_required_plugins_are_installed()
    start_hypernode_vagrant(
        clone_path,
        php_version=php_version,
        xdebug_enabled=xdebug_enabled
    )
    return clone_path
    def test_try_sudo_does_not_try_to_sudo_if_root(self):
        self.geteuid.return_value = 0

        try_sudo()

        self.assertFalse(self.check_call.called)
    def test_try_sudo_gets_euid(self):
        try_sudo()

        self.geteuid.assert_called_once_with()
    def test_try_sudo_does_not_try_to_sudo_if_root(self):
        self.geteuid.return_value = 0

        try_sudo()

        self.assertFalse(self.check_call.called)
    def test_try_sudo_tries_to_sudo_if_not_root(self):
        try_sudo()

        self.check_call.assert_called_once_with("sudo echo 'yes we can sudo'",
                                                shell=True)
    def test_try_sudo_gets_euid(self):
        try_sudo()

        self.geteuid.assert_called_once_with()