Fix some minimal errors.
This commit is contained in:
parent
e9f73c67af
commit
911cf21b74
@ -746,7 +746,7 @@ def _action_dependency_add(context, action_id, field, adds):
|
|||||||
d['l'] = add_list;
|
d['l'] = add_list;
|
||||||
else:
|
else:
|
||||||
d = action[field]
|
d = action[field]
|
||||||
d['l'] = list(set(d['l']) + set(add_list))
|
d['l'] = list(set(d['l']).union(set(add_list)))
|
||||||
action[field] = d
|
action[field] = d
|
||||||
|
|
||||||
if field == 'depends_on':
|
if field == 'depends_on':
|
||||||
|
@ -72,15 +72,6 @@ def create_policy(context, policy=sample_policy, **kwargs):
|
|||||||
data.update(kwargs)
|
data.update(kwargs)
|
||||||
return db_api.policy_create(context, data)
|
return db_api.policy_create(context, data)
|
||||||
|
|
||||||
def create_action(context, action=sample_action, **kwargs):
|
|
||||||
data = parser.parse_action(action)
|
|
||||||
#values = {
|
|
||||||
# 'depends_on': json.loads('{"l" : "[1, 2]"}'),
|
|
||||||
# 'depended_by': json.loads('{"l" : "[4, 5]"}'),
|
|
||||||
#}
|
|
||||||
#data.update(values)
|
|
||||||
data.update(kwargs)
|
|
||||||
return db_api.action_create(context, data)
|
|
||||||
|
|
||||||
def create_cluster(ctx, profile, **kwargs):
|
def create_cluster(ctx, profile, **kwargs):
|
||||||
values = {
|
values = {
|
||||||
@ -147,12 +138,12 @@ def create_action(ctx, **kwargs):
|
|||||||
'target': kwargs.get('target'),
|
'target': kwargs.get('target'),
|
||||||
'action': kwargs.get('action'),
|
'action': kwargs.get('action'),
|
||||||
'cause': 'Reason for action',
|
'cause': 'Reason for action',
|
||||||
'owner': kwarge.get('owner'),
|
'owner': kwargs.get('owner'),
|
||||||
'interval': -1,
|
'interval': -1,
|
||||||
'inputs': {'key': 'value'},
|
'inputs': {'key': 'value'},
|
||||||
'outputs': {'result': 'value'}
|
'outputs': {'result': 'value'},
|
||||||
'depends_on': [],
|
'depends_on': {'l': []},
|
||||||
'depended_on': []
|
'depended_by': {'l': []}
|
||||||
}
|
}
|
||||||
values.update(kwargs)
|
values.update(kwargs)
|
||||||
return db_api.action_create(ctx, values)
|
return db_api.action_create(ctx, values)
|
||||||
|
@ -18,6 +18,11 @@ from senlin.tests.common import utils
|
|||||||
from senlin.tests.db import shared
|
from senlin.tests.db import shared
|
||||||
from senlin.openstack.common import log as logging
|
from senlin.openstack.common import log as logging
|
||||||
|
|
||||||
|
def _create_action(context, action=shared.sample_action, **kwargs):
|
||||||
|
data = parser.parse_action(action)
|
||||||
|
data.update(kwargs)
|
||||||
|
return db_api.action_create(context, data)
|
||||||
|
|
||||||
|
|
||||||
class DBAPIActionTest(base.SenlinTestCase):
|
class DBAPIActionTest(base.SenlinTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -43,7 +48,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
|
|
||||||
def test_action_get(self):
|
def test_action_get(self):
|
||||||
data = parser.parse_action(shared.sample_action)
|
data = parser.parse_action(shared.sample_action)
|
||||||
action = shared.create_action(self.ctx)
|
action = _create_action(self.ctx)
|
||||||
retobj = db_api.action_get(self.ctx, action.id)
|
retobj = db_api.action_get(self.ctx, action.id)
|
||||||
|
|
||||||
self.assertIsNotNone(retobj)
|
self.assertIsNotNone(retobj)
|
||||||
@ -67,7 +72,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
shared.create_action(self.ctx,
|
_create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
|
|
||||||
@ -84,7 +89,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
shared.create_action(self.ctx,
|
_create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
|
|
||||||
@ -104,7 +109,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
shared.create_action(self.ctx,
|
_create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
|
|
||||||
@ -122,7 +127,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
shared.create_action(self.ctx,
|
_create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
|
|
||||||
@ -143,7 +148,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
|
|
||||||
id_of = {}
|
id_of = {}
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
action = shared.create_action(self.ctx,
|
action = _create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
id_of[spec['name']] = action.id
|
id_of[spec['name']] = action.id
|
||||||
@ -184,7 +189,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
|
|
||||||
id_of = {}
|
id_of = {}
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
action = shared.create_action(self.ctx,
|
action = _create_action(self.ctx,
|
||||||
action=shared.sample_action,
|
action=shared.sample_action,
|
||||||
**spec)
|
**spec)
|
||||||
id_of[spec['name']] = action.id
|
id_of[spec['name']] = action.id
|
||||||
@ -281,7 +286,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_action_start_work_on(self):
|
def test_action_start_work_on(self):
|
||||||
action = shared.create_action(self.ctx)
|
action = _create_action(self.ctx)
|
||||||
|
|
||||||
action = db_api.action_start_work_on(self.ctx, action.id, 'worker1')
|
action = db_api.action_start_work_on(self.ctx, action.id, 'worker1')
|
||||||
|
|
||||||
@ -290,7 +295,7 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_action_delete(self):
|
def test_action_delete(self):
|
||||||
action = shared.create_action(self.ctx)
|
action = _create_action(self.ctx)
|
||||||
self.assertIsNotNone(action)
|
self.assertIsNotNone(action)
|
||||||
action_id = action.id
|
action_id = action.id
|
||||||
db_api.action_delete(self.ctx, action.id)
|
db_api.action_delete(self.ctx, action.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user