Esempio n. 1
0
 def test_bind_no_errors(self, mock_query_manager, mock_bind):
     mock_query_manager.return_value.get_group.return_value = {'consumer_ids': ['foo-consumer']}
     binding_config = {'binding': 'foo'}
     agent_options = {'bar': 'baz'}
     mock_bind.return_value = TaskResult(spawned_tasks=[{'task_id': 'foo-request-id'}])
     result = consumer_group.bind('foo_group_id', 'foo_repo_id', 'foo_distributor_id',
                                  True, binding_config, agent_options)
     mock_bind.assert_called_once_with('foo-consumer', 'foo_repo_id', 'foo_distributor_id',
                                       True, binding_config, agent_options)
     self.assertEquals(result.spawned_tasks[0], {'task_id': 'foo-request-id'})
Esempio n. 2
0
    def test_bind_with_general_error(self, mock_query_manager, mock_bind):
        mock_query_manager.return_value.get_group.return_value = {'consumer_ids': ['foo-consumer']}
        binding_config = {'binding': 'foo'}
        agent_options = {'bar': 'baz'}
        side_effect_exception = ValueError()
        mock_bind.side_effect = side_effect_exception

        result = consumer_group.bind('foo_group_id', 'foo_repo_id', 'foo_distributor_id',
                                     True, binding_config, agent_options)
        self.assertTrue(isinstance(result.error, PulpException))
        self.assertEquals(result.error.error_code, error_codes.PLP0004)
        self.assertEquals(result.error.child_exceptions[0], side_effect_exception)
Esempio n. 3
0
    def test_bind_with_general_error(self, mock_query_manager, mock_bind):
        mock_query_manager.return_value.get_group.return_value = {
            'consumer_ids': ['foo-consumer']
        }
        binding_config = {'binding': 'foo'}
        agent_options = {'bar': 'baz'}
        side_effect_exception = ValueError()
        mock_bind.side_effect = side_effect_exception

        result = consumer_group.bind('foo_group_id', 'foo_repo_id',
                                     'foo_distributor_id', True,
                                     binding_config, agent_options)
        self.assertTrue(isinstance(result.error, PulpException))
        self.assertEquals(result.error.error_code, error_codes.PLP0004)
        self.assertEquals(result.error.child_exceptions[0],
                          side_effect_exception)
Esempio n. 4
0
 def test_bind_no_errors(self, mock_query_manager, mock_bind):
     mock_query_manager.return_value.get_group.return_value = {
         'consumer_ids': ['foo-consumer']
     }
     binding_config = {'binding': 'foo'}
     agent_options = {'bar': 'baz'}
     mock_bind.return_value = TaskResult(
         spawned_tasks=[{
             'task_id': 'foo-request-id'
         }])
     result = consumer_group.bind('foo_group_id', 'foo_repo_id',
                                  'foo_distributor_id', True,
                                  binding_config, agent_options)
     mock_bind.assert_called_once_with('foo-consumer', 'foo_repo_id',
                                       'foo_distributor_id', True,
                                       binding_config, agent_options)
     self.assertEquals(result.spawned_tasks[0],
                       {'task_id': 'foo-request-id'})