def cli():
    """Runs module from the CLI"""
    color_output = ColorOutput()
    subcommands = OrderedDict()
    subcommands['init'] = Subcommand(
        'init',
        help_string=(
            "Equivalent to %s" %
            (color_output('git autorelease quick 0.0.0', style='bold'))),
        release_commands=['start', 'finish'],
        has_version=False,
        has_base=True)
    subcommands['quick'] = Subcommand(
        'quick',
        help_string=("Starts and finishes a release (%s; %s)" % (
            color_output('git flow release start <version> <base>',
                         style='bold'),
            color_output('git flow release finish <version>', style='bold'),
        )),
        release_commands=['start', 'finish'],
        has_version=True,
        version_optional=False,
        has_base=True)
    subcommands['start'] = Subcommand(
        'start',
        help_string=("Starts a release (%s)" % (color_output(
            'git flow release start <version> <base>', style='bold'))),
        release_commands=['start'],
        has_version=True,
        version_optional=False,
        has_base=True)
    subcommands['finish'] = Subcommand(
        'finish',
        help_string=("Finishes a release (%s)" % (color_output(
            'git flow release finish <version>', style='bold'), )),
        release_commands=['finish'],
        has_version=True,
        version_optional=True,
        has_base=False)
    subcommands['publish'] = Subcommand(
        'publish',
        help_string=("Publishes a release branch (%s)" % (color_output(
            'git flow release publish <version>', style='bold'))),
        release_commands=['publish'],
        has_version=True,
        version_optional=True,
        has_base=False)
    subcommands['delete'] = Subcommand(
        'delete',
        help_string=(
            "Deletes a release branch (%s)" %
            (color_output('git flow release delete <version>', style='bold'))),
        release_commands=['delete'],
        has_version=True,
        version_optional=True,
        has_base=False)
    app = Application(subcommands)
    app.bootstrap()
 def test_call(self):
     self.mock_color_output.assert_not_called()
     self.mock_color.assert_not_called()
     self.assertEqual(Application.all_help_prog_header(self.parser),
                      self.RESULT)
     self.mock_color_output.assert_called_once()
     self.mock_color.assert_called_once()
 def test_call(self):
     self.mock_color_output.assert_not_called()
     self.mock_color.assert_not_called()
     self.assertEqual(
         Application.all_help_prog_header(self.parser),
         self.RESULT
     )
     self.mock_color_output.assert_called_once()
     self.mock_color.assert_called_once()
 def test_call(self):
     self.mock_argumentparser.assert_not_called()
     self.mock_parser_add.assert_not_called()
     self.assertEqual(
         Application.create_root_parser(),
         self.parser
     )
     self.mock_argumentparser.assert_called_once()
     self.mock_parser_add.assert_called_once()
 def construct_application(self):
     ensure_git_flow_patcher = patch(
         'gitflow_easyrelease.application.RepoInfo.ensure_git_flow',
         return_value=True)
     self.mock_ensure_git_flow = ensure_git_flow_patcher.start()
     self.addCleanup(ensure_git_flow_patcher.stop)
     self.mock_sub_attach = MagicMock()
     self.mock_sub_execute = MagicMock()
     subcommands = OrderedDict({
         self.SUBCOMMAND_KEY:
         MagicMock(attach_subparser=self.mock_sub_attach,
                   execute=self.mock_sub_execute)
     })
     self.application = Application(subcommands)
     self.subparsers = MagicMock()
     self.mock_parser_add = MagicMock(return_value=self.subparsers)
     self.parser = MagicMock(add_subparsers=self.mock_parser_add,
                             add_argument=self.mock_parser_add,
                             parse_known_args=self.mock_parser_add)
 def test_subparser_help(self):
     self.mock_subparser_help.assert_not_called()
     Application.print_all_help(self.parser)
     self.mock_subparser_help.assert_called_with()
 def test_exit(self):
     self.mock_sys_exit.assert_not_called()
     Application.print_all_help(self.parser)
     self.mock_sys_exit.assert_called_once_with(0)
 def test_with_args(self):
     self.mock_parser_add.assert_not_called()
     Application.parse_args(self.parser, ['qqq'])
     self.mock_parser_add.assert_called_once_with(['qqq'])
 def test_without_args(self):
     self.mock_parser_add.assert_not_called()
     Application.parse_args(self.parser)
     self.mock_parser_add.assert_called_once_with(['-h'])
 def test_call(self):
     self.mock_argumentparser.assert_not_called()
     self.mock_parser_add.assert_not_called()
     self.assertEqual(Application.create_root_parser(), self.parser)
     self.mock_argumentparser.assert_called_once()
     self.mock_parser_add.assert_called_once()
def cli():
    """Runs module from the CLI"""
    color_output = ColorOutput()
    subcommands = OrderedDict()
    subcommands['init'] = Subcommand(
        'init',
        help_string=(
            "Equivalent to %s"
            % (
                color_output('git autorelease quick 0.0.0', style='bold')
            )
        ),
        release_commands=['start', 'finish'],
        has_version=False,
        has_base=True
    )
    subcommands['quick'] = Subcommand(
        'quick',
        help_string=(
            "Starts and finishes a release (%s; %s)"
            % (
                color_output(
                    'git flow release start <version> <base>',
                    style='bold'
                ),
                color_output(
                    'git flow release finish <version>',
                    style='bold'
                ),
            )
        ),
        release_commands=['start', 'finish'],
        has_version=True,
        version_optional=False,
        has_base=True
    )
    subcommands['start'] = Subcommand(
        'start',
        help_string=(
            "Starts a release (%s)"
            % (
                color_output(
                    'git flow release start <version> <base>',
                    style='bold'
                )
            )
        ),
        release_commands=['start'],
        has_version=True,
        version_optional=False,
        has_base=True
    )
    subcommands['finish'] = Subcommand(
        'finish',
        help_string=(
            "Finishes a release (%s)"
            % (
                color_output(
                    'git flow release finish <version>',
                    style='bold'
                ),
            )
        ),
        release_commands=['finish'],
        has_version=True,
        version_optional=True,
        has_base=False
    )
    subcommands['publish'] = Subcommand(
        'publish',
        help_string=(
            "Publishes a release branch (%s)"
            % (
                color_output(
                    'git flow release publish <version>',
                    style='bold'
                )
            )
        ),
        release_commands=['publish'],
        has_version=True,
        version_optional=True,
        has_base=False
    )
    subcommands['delete'] = Subcommand(
        'delete',
        help_string=(
            "Deletes a release branch (%s)"
            % (
                color_output(
                    'git flow release delete <version>',
                    style='bold'
                )
            )
        ),
        release_commands=['delete'],
        has_version=True,
        version_optional=True,
        has_base=False
    )
    app = Application(subcommands)
    app.bootstrap()
 def test_subparser_help(self):
     self.mock_subparser_help.assert_not_called()
     Application.print_all_help(self.parser)
     self.mock_subparser_help.assert_called_with()
 def test_exit(self):
     self.mock_sys_exit.assert_not_called()
     Application.print_all_help(self.parser)
     self.mock_sys_exit.assert_called_once_with(0)
 def test_with_args(self):
     self.mock_parser_add.assert_not_called()
     Application.parse_args(self.parser, ['qqq'])
     self.mock_parser_add.assert_called_once_with(['qqq'])
 def test_without_args(self):
     self.mock_parser_add.assert_not_called()
     Application.parse_args(self.parser)
     self.mock_parser_add.assert_called_once_with(['-h'])