Merge "Fix updating datasource without changing a name"

This commit is contained in:
Jenkins 2016-03-14 14:30:15 +00:00 committed by Gerrit Code Review
commit 43f08a562b
2 changed files with 6 additions and 3 deletions

View File

@ -118,10 +118,10 @@ def check_data_source_update(data, data_source_id):
_("DataSource is used in a "
"PENDING Job and can not be updated."))
if 'name' in data:
ds = c.API.data_source_get(ctx, data_source_id)
if 'name' in data and data['name'] != ds.name:
b.check_data_source_unique_name(data['name'])
ds = c.API.data_source_get(ctx, data_source_id)
check_data = {'type': data.get('type', None) or ds.type,
'url': data.get('url', None) or ds.url,
'credentials': data.get(

View File

@ -401,7 +401,7 @@ class TestDataSourceUpdateValidation(u.ValidationTestCase):
@mock.patch('sahara.conductor.API.job_execution_get_all')
@mock.patch('sahara.conductor.API.data_source_get_all')
@mock.patch('sahara.conductor.API.data_source_get')
def test_update_data_source_name(self, je_all, ds_all, ds_get):
def test_update_data_source_name(self, ds_get, ds_all, je_all):
ds1 = mock.Mock()
ds1.name = 'ds1'
ds_all.return_value = [ds1]
@ -411,6 +411,9 @@ class TestDataSourceUpdateValidation(u.ValidationTestCase):
with testtools.ExpectedException(ex.NameAlreadyExistsException):
ds.check_data_source_update({'name': 'ds'}, 'ds_id')
ds_get.return_value = ds1
ds.check_data_source_update({'name': 'ds'}, 'ds_id')
@mock.patch('sahara.conductor.API.job_execution_get_all')
@mock.patch('sahara.conductor.API.data_source_get')
def test_update_data_source_swift(self, ds_get, je_all):