Example #1
0
def write_hypernode_vagrant_configuration(
        directory,
        php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
        xdebug_enabled=False,
        xenial=False):
    """
    Write the hypernode-vagrant local.yml configuration file to the
    hypernode-vagrant directory.
    :param str directory: The hypernode-vagrant checkout directory
    :param str php_version: The PHP version to use
    :param bool xdebug_enabled: Install xdebug in the vagrant
    :param bool xenial: Start a Xenial image
    :return None:
    """
    log.info("Writing configuration file to the hypernode-vagrant directory")
    local_yml_path = join(directory, 'local.yml')
    file_handle = open(local_yml_path, 'w')
    configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
        xdebug_enabled='true' if xdebug_enabled else 'false',
        php_version=php_version,
        box_name=HYPERNODE_XENIAL_BOX_NAME
        if xenial else HYPERNODE_VAGRANT_BOX_NAMES[php_version],
        box_url=HYPERNODE_XENIAL_URL
        if xenial else HYPERNODE_VAGRANT_BOX_URLS[php_version],
        ubuntu_version="xenial" if xenial else "precise")
    file_handle.write(configuration)
    file_handle.close()
    def test_write_hypernode_vagrant_configuration_writes_config_with_specified_php_version(
            self):
        write_hypernode_vagrant_configuration(self.temp_dir, php_version='5.5')

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            php_version='5.5',
            box_name=HYPERNODE_VAGRANT_BOX_NAMES['5.5'],
            box_url=HYPERNODE_VAGRANT_BOX_URLS['5.5'])
        self.assertEqual(ret, expected_configuration)
    def test_write_hypernode_vagrant_configuration_writes_configuration(self):
        write_hypernode_vagrant_configuration(self.temp_dir)

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
            box_name=HYPERNODE_VAGRANT_BOX_NAMES[
                HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION],
            box_url=HYPERNODE_VAGRANT_BOX_URLS[
                HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION])
        self.assertEqual(ret, expected_configuration)
    def test_write_hypernode_vagrant_configuration_writes_writes_config_with_xenial_image_if_specified(self):
        write_hypernode_vagrant_configuration(self.temp_dir, xenial=True)

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            xdebug_enabled='false',
            php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
            box_name=HYPERNODE_XENIAL_BOX_NAME,
            box_url=HYPERNODE_XENIAL_URL,
            ubuntu_version='xenial'
        )
        self.assertEqual(ret, expected_configuration)
Example #5
0
    def test_write_hypernode_vagrant_configuration_writes_writes_config_with_xenial_image_if_specified(
            self):
        write_hypernode_vagrant_configuration(self.temp_dir, xenial=True)

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            xdebug_enabled='false',
            php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
            box_name=HYPERNODE_XENIAL_BOX_NAME,
            box_url=HYPERNODE_XENIAL_URL,
            ubuntu_version='xenial')
        self.assertEqual(ret, expected_configuration)
    def test_write_hypernode_vagrant_configuration_writes_config_with_specified_xenial_exclusive_php_version(self):
        write_hypernode_vagrant_configuration(self.temp_dir, php_version='7.1')
        # PHP 7.1 is not available in the Ubuntu Precise hypernode-vagrant

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            xdebug_enabled='false',
            php_version='7.1',
            box_name=HYPERNODE_XENIAL_BOX_NAME,
            box_url=HYPERNODE_XENIAL_URL,
            ubuntu_version='xenial'
        )
        self.assertEqual(ret, expected_configuration)
Example #7
0
    def test_write_hypernode_vagrant_configuration_writes_config_with_specified_xenial_exclusive_php_version(
            self):
        write_hypernode_vagrant_configuration(self.temp_dir, php_version='7.1')
        # PHP 7.1 is not available in the Ubuntu Precise hypernode-vagrant

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            xdebug_enabled='false',
            php_version='7.1',
            box_name=HYPERNODE_XENIAL_BOX_NAME,
            box_url=HYPERNODE_XENIAL_URL,
            ubuntu_version='xenial')
        self.assertEqual(ret, expected_configuration)
Example #8
0
    def test_write_hypernode_vagrant_configuration_writes_configuration(self):
        write_hypernode_vagrant_configuration(self.temp_dir, xenial=False)

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
            xdebug_enabled='false',
            php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
            box_name=HYPERNODE_VAGRANT_BOX_NAMES[
                HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION],
            box_url=HYPERNODE_VAGRANT_BOX_URLS[
                HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION],
            ubuntu_version='precise')
        self.assertEqual(ret, expected_configuration)
    def test_write_hypernode_vagrant_configuration_writes_config_with_xdebug_enabled_if_specified(self):
        write_hypernode_vagrant_configuration(self.temp_dir, xdebug_enabled=True)

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
                xdebug_enabled='true',
                php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
                box_name=HYPERNODE_VAGRANT_BOX_NAMES[
                    HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION
                ],
                box_url=HYPERNODE_VAGRANT_BOX_URLS[
                    HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION
                ]
        )
        self.assertEqual(ret, expected_configuration)
    def test_write_hypernode_vagrant_configuration_writes_config_with_specified_php_version(self):
        write_hypernode_vagrant_configuration(self.temp_dir, php_version='5.5')

        with open(self.temp_config_file) as f:
            ret = f.read()
        expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
                xdebug_enabled='false',
                php_version='5.5',
                box_name=HYPERNODE_VAGRANT_BOX_NAMES[
                    '5.5'
                ],
                box_url=HYPERNODE_VAGRANT_BOX_URLS[
                    '5.5'
                ]
        )
        self.assertEqual(ret, expected_configuration)
Example #11
0
def write_hypernode_vagrant_configuration(
        directory, php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION):
    """
    Write the hypernode-vagrant local.yml configuration file to the
    hypernode-vagrant directory.
    :param str directory: The hypernode-vagrant checkout directory
    :param str php_version: The PHP version to use
    :return None:
    """
    log.info("Writing configuration file to the hypernode-vagrant directory")
    local_yml_path = join(directory, 'local.yml')
    file_handle = open(local_yml_path, 'w')
    configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
        php_version=php_version,
        box_name=HYPERNODE_VAGRANT_BOX_NAMES[php_version],
        box_url=HYPERNODE_VAGRANT_BOX_URLS[php_version])
    file_handle.write(configuration)
    file_handle.close()
Example #12
0
def write_hypernode_vagrant_configuration(
        directory,
        php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION,
        xdebug_enabled=False
):
    """
    Write the hypernode-vagrant local.yml configuration file to the
    hypernode-vagrant directory.
    :param str directory: The hypernode-vagrant checkout directory
    :param str php_version: The PHP version to use
    :param bool xdebug_enabled: Install xdebug in the vagrant
    :return None:
    """
    log.info("Writing configuration file to the hypernode-vagrant directory")
    local_yml_path = join(directory, 'local.yml')
    file_handle = open(local_yml_path, 'w')
    configuration = HYPERNODE_VAGRANT_CONFIGURATION.format(
        xdebug_enabled='true' if xdebug_enabled else 'false',
        php_version=php_version,
        box_name=HYPERNODE_VAGRANT_BOX_NAMES[php_version],
        box_url=HYPERNODE_VAGRANT_BOX_URLS[php_version]
    )
    file_handle.write(configuration)
    file_handle.close()