Beispiel #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 = cud.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'})
Beispiel #2
0
    def test_bind_with_missing_resource_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'}
        side_effect_exception = MissingResource()
        mock_bind.side_effect = side_effect_exception

        result = cud.bind('foo_group_id', 'foo_repo_id', 'foo_distributor_id',
                          True, binding_config, agent_options)
        self.assertTrue(result.error.error_code is error_codes.PLP0004)
        self.assertEquals(result.error.child_exceptions[0], side_effect_exception)
Beispiel #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 = cud.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)
Beispiel #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 = cud.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'})