Beispiel #1
0
    def test_base_arguments_only(self):
        base_func = Mock()
        args = ['foo', 'bar']
        kwargs = {'baz': 'qux'}
        wrapped_func = util.partial(base_func, *args, **kwargs)

        wrapped_func()
        base_func.assert_called_once_with(*args, **kwargs)
Beispiel #2
0
    def test_base_arguments_only(self):
        base_func = Mock()
        args = ['foo', 'bar']
        kwargs = {'baz': 'qux'}
        wrapped_func = util.partial(base_func, *args, **kwargs)

        wrapped_func()
        base_func.assert_called_once_with(*args, **kwargs)
Beispiel #3
0
    def test_additional_args(self):
        base_func = Mock()
        args = ['foo', 'bar']
        kwargs = {'baz': 'qux'}
        wrapped_func = util.partial(base_func, *args, **kwargs)

        additional_args = ['alpha', 'bravo']
        additional_kwargs = {'charlie': 'delta'}
        wrapped_func(*additional_args, **additional_kwargs)

        result_args = args + additional_args
        result_kwargs = {}
        result_kwargs.update(kwargs)
        result_kwargs.update(additional_kwargs)
        base_func.assert_called_once_with(*result_args, **result_kwargs)
Beispiel #4
0
    def test_additional_args(self):
        base_func = Mock()
        args = ['foo', 'bar']
        kwargs = {'baz': 'qux'}
        wrapped_func = util.partial(base_func, *args, **kwargs)

        additional_args = ['alpha', 'bravo']
        additional_kwargs = {'charlie': 'delta'}
        wrapped_func(*additional_args, **additional_kwargs)

        result_args = args + additional_args
        result_kwargs = {}
        result_kwargs.update(kwargs)
        result_kwargs.update(additional_kwargs)
        base_func.assert_called_once_with(*result_args, **result_kwargs)
Beispiel #5
0
    def display_task_results(self, task, success_string, error_string):
        """
        :param task: the task that was run
        :type task: task
        :param success_string: The string to display before showing the successfully processed units
        :type success_string: str
        :param error_string: The string to display before showing the units that failed processing
        :type error_string: str
        """
        result = task.result  # entries are a dict containing unit_key and type_id
        units_successful = result.get('units_successful', [])
        units_failed = result.get('units_failed', [])
        total_units = len(units_successful) + len(units_failed)
        unit_threshold_reached = self.max_units_displayed < (
            len(units_successful) + len(units_failed))

        if total_units == 0:
            self.prompt.write(_(
                'Nothing found that matches the given criteria and '
                'repository configuration'),
                              tag='too-few')
        else:
            # Display the successfully processed units
            self.prompt.write(success_string)
            if len(units_successful) == 0:
                self.prompt.write(_('  None'), tag="none")
            elif unit_threshold_reached:
                self._summary(self.prompt.write, units_successful)
            else:
                self._details(self.prompt.write, units_successful)

            if len(units_failed) > 0:
                func_args = []
                func_kwargs = {'color': COLOR_FAILURE}
                error_prompt = util.partial(self.prompt.write, *func_args,
                                            **func_kwargs)
                error_prompt(error_string)
                # Display the units we were unable to remove
                if unit_threshold_reached:
                    self._summary(self.prompt.write, units_failed)
                else:
                    self._details(error_prompt, units_failed)
Beispiel #6
0
    def display_task_results(self, task, success_string, error_string):
        """
        :param task: the task that was run
        :type task: task
        :param success_string: The string to display before showing the successfully processed units
        :type success_string: str
        :param error_string: The string to display before showing the units that failed processing
        :type error_string: str
        """
        result = task.result  # entries are a dict containing unit_key and type_id
        units_successful = result.get('units_successful', [])
        units_failed = result.get('units_failed', [])
        total_units = len(units_successful) + len(units_failed)
        unit_threshold_reached = self.max_units_displayed < (len(units_successful) +
                                                             len(units_failed))

        if total_units == 0:
            self.prompt.write(_('Nothing found that matches the given criteria and '
                                'repository configuration'), tag='too-few')
        else:
            # Display the successfully processed units
            self.prompt.write(success_string)
            if len(units_successful) == 0:
                self.prompt.write(_('  None'), tag="none")
            elif unit_threshold_reached:
                self._summary(self.prompt.write, units_successful)
            else:
                self._details(self.prompt.write, units_successful)

            if len(units_failed) > 0:
                func_args = []
                func_kwargs = {'color': COLOR_FAILURE}
                error_prompt = util.partial(self.prompt.write, *func_args, **func_kwargs)
                error_prompt(error_string)
                # Display the units we were unable to remove
                if unit_threshold_reached:
                    self._summary(self.prompt.write, units_failed)
                else:
                    self._details(error_prompt, units_failed)
Beispiel #7
0
    def test_no_arguments(self):
        base_func = Mock()
        wrapped_func = util.partial(base_func)

        wrapped_func()
        base_func.assert_called_once_with()
Beispiel #8
0
    def test_no_arguments(self):
        base_func = Mock()
        wrapped_func = util.partial(base_func)

        wrapped_func()
        base_func.assert_called_once_with()