Fix updating datasource without changing a name

Change-Id: I1c0a3497ace2a4eb76b0ddd3c3de785478b263d0
Closes-bug: 1554994
This commit is contained in:
Vitaly Gridnev 2016-03-11 17:22:53 +03:00
parent a931356541
commit 4053e0217b
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):