def test_version_prompt(self): """ The ``version-prompt`` directive replaces the placemarker ``|latest-installable|`` in a source file with the current installable version in the output file. """ source_directory = self.make_temporary_directory() source_file = source_directory.child('contents.rst') source_file.setContent(dedent(''' .. version-prompt:: bash $ $ PRE-|latest-installable|-POST ''')) destination_directory = self.make_temporary_directory() run_process([ 'sphinx-build', '-b', 'html', '-C', # don't look for config file, use -D flags instead '-D', 'extensions=flocker.docs.version_extensions', # directory containing source/config files source_directory.path, # directory containing build files destination_directory.path, source_file.path]) # source file to process expected = 'PRE-{}-POST'.format(get_installable_version(version)) content = destination_directory.child('contents.html').getContent() self.assertIn(expected, content)
def test_version_prompt(self): """ The ``version-prompt`` directive replaces the placemarker ``|latest-installable|`` in a source file with the current installable version in the output file. """ temp_dir = FilePath(self.mktemp()) temp_dir.makedirs() source_file = temp_dir.child('contents.rst') source_file.setContent( dedent(''' .. version-prompt:: bash $ $ PRE-|latest-installable|-POST ''')) run_process([ 'sphinx-build', '-b', 'html', '-C', # don't look for config file, use -D flags instead '-D', 'extensions=flocker.docs.version_extensions', temp_dir.path, # directory containing source/config files temp_dir.path, # directory containing build files source_file.path ]) # source file to process expected = 'PRE-{}-POST'.format(get_installable_version(version)) content = temp_dir.child('contents.html').getContent() self.assertIn(expected, content)
def test_help(self): """ The script is executable and has some meaningful ``--help``. """ result = run_process( [INITIALIZE_RELEASE_PATH.path, '--help'] ) self.expectThat(result.status, Equals(0)) self.expectThat(result.output, Contains('Usage: initialize-release'))
def _run_cloudformation_with_cluster_size(self, cluster_size): """ Create CloudFormation template for a cluster of desired size. :param int: Desired number of cluster nodes in the template. :raises: CalledProcessError :returns: Result of running ``python cloudformation.py -s {cluster_size}``. :rtype: _ProcessResult """ run_process_args = [ b'/usr/bin/env', b'python', self._cloudformation_file.path, b"-s", str(cluster_size) ] result = run_process(run_process_args) return result
def _run_cloudformation_with_cluster_size(self, cluster_size): """ Create CloudFormation template for a cluster of desired size. :param int: Desired number of cluster nodes in the template. :raises: CalledProcessError :returns: Result of running ``python cloudformation.py -s {cluster_size}``. :rtype: _ProcessResult """ run_process_args = [b'/usr/bin/env', b'python', self._cloudformation_file.path, b"-s", str(cluster_size)] result = run_process(run_process_args) return result
def test_run(self): """ The script creates a new release version branch in a new working directory and prints some shell commands to ``stdout``. """ expected_version = "9.9.9" script_path = self.make_temporary_directory() repo_path = script_path.sibling( 'flocker-release-{}'.format(expected_version) ) result = run_process( [INITIALIZE_RELEASE_PATH.path, '--flocker-version={}'.format(expected_version)], cwd=script_path.path ) self.expectThat(result.status, Equals(0)) self.expectThat( result.output, Contains('export VERSION={}'.format(expected_version)) ) self.expectThat( Repo(path=repo_path.path).active_branch.name, Equals('release/flocker-{}'.format(expected_version)) )