def test_install(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.install_content mock_task.return_value = {'task_id': 'foo-request-id'} result = consumer_group.install_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'})
def test_install_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.install_content side_effect_exception = ValueError() mock_task.side_effect = side_effect_exception result = consumer_group.install_content(group_id, units, agent_options) self.assertTrue(isinstance(result.error, PulpException)) self.assertEquals(result.error.error_code, error_codes.PLP0020) self.assertEquals(result.error.child_exceptions[0], side_effect_exception)
def test_install(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.install_content mock_task.return_value = {'task_id': 'foo-request-id'} result = consumer_group.install_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'})
def install(self, consumer_group_id): """ Install content (units) on 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 install 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.install_content(consumer_group_id, units, options) raise pulp_exceptions.OperationPostponed(task)
def test_install_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.install_content side_effect_exception = ValueError() mock_task.side_effect = side_effect_exception result = consumer_group.install_content(group_id, units, agent_options) self.assertTrue(isinstance(result.error, PulpException)) self.assertEquals(result.error.error_code, error_codes.PLP0020) self.assertEquals(result.error.child_exceptions[0], side_effect_exception)