Example #1
0
    def test_uninstall(self, mock_query_manager, mock_agent_manager):
        mock_query_manager.return_value.get_group.return_value = {'consumer_ids': ['foo-consumer']}
        group_id = 'foo-group'
        units = ['foo', 'bar']
        agent_options = {'bar': 'baz'}
        mock_task = mock_agent_manager.return_value.uninstall_content

        mock_task.return_value = {'task_id': 'foo-request-id'}
        result = consumer_group.uninstall_content(group_id, units, agent_options)

        mock_task.assert_called_once_with('foo-consumer', units, agent_options)
        self.assertEquals(result.spawned_tasks[0], {'task_id': 'foo-request-id'})
Example #2
0
    def test_uninstall_with_general_error(self, mock_query_manager, mock_agent_manager):
        mock_query_manager.return_value.get_group.return_value = {'consumer_ids': ['foo-consumer']}
        group_id = 'foo-group'
        units = ['foo', 'bar']
        agent_options = {'bar': 'baz'}
        mock_task = mock_agent_manager.return_value.uninstall_content
        side_effect_exception = ValueError()
        mock_task.side_effect = side_effect_exception

        result = consumer_group.uninstall_content(group_id, units, agent_options)

        self.assertTrue(isinstance(result.error, PulpException))
        self.assertEquals(result.error.error_code, error_codes.PLP0022)
        self.assertEquals(result.error.child_exceptions[0], side_effect_exception)
Example #3
0
    def test_uninstall(self, mock_query_manager, mock_agent_manager):
        mock_query_manager.return_value.get_group.return_value = {
            'consumer_ids': ['foo-consumer']
        }
        group_id = 'foo-group'
        units = ['foo', 'bar']
        agent_options = {'bar': 'baz'}
        mock_task = mock_agent_manager.return_value.uninstall_content

        mock_task.return_value = {'task_id': 'foo-request-id'}
        result = consumer_group.uninstall_content(group_id, units,
                                                  agent_options)

        mock_task.assert_called_once_with('foo-consumer', units, agent_options)
        self.assertEquals(result.spawned_tasks[0],
                          {'task_id': 'foo-request-id'})
Example #4
0
 def uninstall(self, consumer_group_id):
     """
     Uninstall content (units) from the consumers in a consumer group.
     Expected body: {units:[], options:<dict>}
     where unit is: {type_id:<str>, unit_key={}} and the
     options is a dict of uninstall options.
     @param consumer_group_id: A consumer group ID.
     @type consumer_group_id: str
     @return: list of call requests
     @rtype: list
     """
     body = self.params()
     units = body.get('units')
     options = body.get('options')
     task = consumer_group.uninstall_content(consumer_group_id, units, options)
     raise pulp_exceptions.OperationPostponed(task)
Example #5
0
 def uninstall(self, consumer_group_id):
     """
     Uninstall content (units) from the consumers in a consumer group.
     Expected body: {units:[], options:<dict>}
     where unit is: {type_id:<str>, unit_key={}} and the
     options is a dict of uninstall options.
     @param consumer_group_id: A consumer group ID.
     @type consumer_group_id: str
     @return: list of call requests
     @rtype: list
     """
     body = self.params()
     units = body.get('units')
     options = body.get('options')
     task = consumer_group.uninstall_content(consumer_group_id, units,
                                             options)
     raise pulp_exceptions.OperationPostponed(task)
Example #6
0
    def test_uninstall_with_general_error(self, mock_query_manager,
                                          mock_agent_manager):
        mock_query_manager.return_value.get_group.return_value = {
            'consumer_ids': ['foo-consumer']
        }
        group_id = 'foo-group'
        units = ['foo', 'bar']
        agent_options = {'bar': 'baz'}
        mock_task = mock_agent_manager.return_value.uninstall_content
        side_effect_exception = ValueError()
        mock_task.side_effect = side_effect_exception

        result = consumer_group.uninstall_content(group_id, units,
                                                  agent_options)

        self.assertTrue(isinstance(result.error, PulpException))
        self.assertEquals(result.error.error_code, error_codes.PLP0022)
        self.assertEquals(result.error.child_exceptions[0],
                          side_effect_exception)