Use Enum value instead of String Value
Fixing Gating Issue. Change-Id: I64a0df9e27e09172119a3a8f5395204b7476f23d
This commit is contained in:
@@ -20,7 +20,7 @@ import six
|
||||
|
||||
from watcher.common import exception
|
||||
from watcher.common import utils as w_utils
|
||||
from watcher.objects import action as act_objects
|
||||
from watcher import objects
|
||||
from watcher.tests.db import base
|
||||
from watcher.tests.db import utils
|
||||
|
||||
@@ -68,15 +68,15 @@ class TestDbActionFilters(base.DbTestCase):
|
||||
with freezegun.freeze_time(self.FAKE_TODAY):
|
||||
self.dbapi.update_action(
|
||||
self.action1.uuid,
|
||||
values={"state": act_objects.State.SUCCEEDED})
|
||||
values={"state": objects.action_plan.State.SUCCEEDED})
|
||||
with freezegun.freeze_time(self.FAKE_OLD_DATE):
|
||||
self.dbapi.update_action(
|
||||
self.action2.uuid,
|
||||
values={"state": act_objects.State.SUCCEEDED})
|
||||
values={"state": objects.action_plan.State.SUCCEEDED})
|
||||
with freezegun.freeze_time(self.FAKE_OLDER_DATE):
|
||||
self.dbapi.update_action(
|
||||
self.action3.uuid,
|
||||
values={"state": act_objects.State.SUCCEEDED})
|
||||
values={"state": objects.action_plan.State.SUCCEEDED})
|
||||
|
||||
def test_get_action_filter_deleted_true(self):
|
||||
with freezegun.freeze_time(self.FAKE_TODAY):
|
||||
@@ -259,30 +259,31 @@ class DbActionTestCase(base.DbTestCase):
|
||||
uuid=w_utils.generate_uuid(),
|
||||
audit_id=audit.id,
|
||||
first_action_id=None,
|
||||
state='RECOMMENDED')
|
||||
state=objects.action_plan.State.RECOMMENDED)
|
||||
action1 = self._create_test_action(
|
||||
id=1,
|
||||
action_plan_id=1,
|
||||
description='description action 1',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
next=None,
|
||||
state='PENDING')
|
||||
state=objects.action_plan.State.PENDING)
|
||||
action2 = self._create_test_action(
|
||||
id=2,
|
||||
action_plan_id=2,
|
||||
description='description action 2',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
next=action1['uuid'],
|
||||
state='PENDING')
|
||||
state=objects.action_plan.State.PENDING)
|
||||
action3 = self._create_test_action(
|
||||
id=3,
|
||||
action_plan_id=1,
|
||||
description='description action 3',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
next=action2['uuid'],
|
||||
state='ONGOING')
|
||||
res = self.dbapi.get_action_list(self.context,
|
||||
filters={'state': 'ONGOING'})
|
||||
state=objects.action_plan.State.ONGOING)
|
||||
res = self.dbapi.get_action_list(
|
||||
self.context,
|
||||
filters={'state': objects.action_plan.State.ONGOING})
|
||||
self.assertEqual([action3['id']], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_action_list(self.context,
|
||||
@@ -331,8 +332,9 @@ class DbActionTestCase(base.DbTestCase):
|
||||
|
||||
def test_update_action(self):
|
||||
action = self._create_test_action()
|
||||
res = self.dbapi.update_action(action['id'], {'state': 'CANCELLED'})
|
||||
self.assertEqual('CANCELLED', res.state)
|
||||
res = self.dbapi.update_action(
|
||||
action['id'], {'state': objects.action_plan.State.CANCELLED})
|
||||
self.assertEqual(objects.action_plan.State.CANCELLED, res.state)
|
||||
|
||||
def test_update_action_that_does_not_exist(self):
|
||||
self.assertRaises(exception.ActionNotFound,
|
||||
|
||||
@@ -255,28 +255,28 @@ class DbActionPlanTestCase(base.DbTestCase):
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING')
|
||||
state=ap_objects.State.ONGOING)
|
||||
action_plan1 = self._create_test_action_plan(
|
||||
id=1,
|
||||
uuid=w_utils.generate_uuid(),
|
||||
audit_id=audit['id'],
|
||||
first_action_id=None,
|
||||
state='RECOMMENDED')
|
||||
state=ap_objects.State.RECOMMENDED)
|
||||
action_plan2 = self._create_test_action_plan(
|
||||
id=2,
|
||||
uuid=w_utils.generate_uuid(),
|
||||
audit_id=audit['id'],
|
||||
first_action_id=action_plan1['id'],
|
||||
state='ONGOING')
|
||||
state=ap_objects.State.ONGOING)
|
||||
|
||||
res = self.dbapi.get_action_plan_list(
|
||||
self.context,
|
||||
filters={'state': 'RECOMMENDED'})
|
||||
filters={'state': ap_objects.State.RECOMMENDED})
|
||||
self.assertEqual([action_plan1['id']], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_action_plan_list(
|
||||
self.context,
|
||||
filters={'state': 'ONGOING'})
|
||||
filters={'state': ap_objects.State.ONGOING})
|
||||
self.assertEqual([action_plan2['id']], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_action_plan_list(
|
||||
|
||||
@@ -270,13 +270,13 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING')
|
||||
state=audit_objects.State.ONGOING)
|
||||
audit2 = self._create_test_audit(
|
||||
id=2,
|
||||
audit_type='CONTINUOUS',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='PENDING')
|
||||
state=audit_objects.State.PENDING)
|
||||
|
||||
res = self.dbapi.get_audit_list(self.context,
|
||||
filters={'audit_type': 'ONESHOT'})
|
||||
@@ -288,12 +288,12 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
|
||||
res = self.dbapi.get_audit_list(
|
||||
self.context,
|
||||
filters={'state': 'ONGOING'})
|
||||
filters={'state': audit_objects.State.ONGOING})
|
||||
self.assertEqual([audit1['id']], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_audit_list(
|
||||
self.context,
|
||||
filters={'state': 'PENDING'})
|
||||
filters={'state': audit_objects.State.PENDING})
|
||||
self.assertEqual([audit2['id']], [r.id for r in res])
|
||||
|
||||
def test_get_audit_list_with_filter_by_uuid(self):
|
||||
|
||||
@@ -20,6 +20,7 @@ import six
|
||||
|
||||
from watcher.common import exception
|
||||
from watcher.common import utils as w_utils
|
||||
from watcher import objects
|
||||
from watcher.tests.db import base
|
||||
from watcher.tests.db import utils
|
||||
|
||||
@@ -271,7 +272,7 @@ class DbEfficacyIndicatorTestCase(base.DbTestCase):
|
||||
uuid=w_utils.generate_uuid(),
|
||||
audit_id=audit.id,
|
||||
first_efficacy_indicator_id=None,
|
||||
state='RECOMMENDED')
|
||||
state=objects.action_plan.State.RECOMMENDED)
|
||||
efficacy_indicator1 = self._create_test_efficacy_indicator(
|
||||
id=1,
|
||||
name='indicator_1',
|
||||
@@ -341,7 +342,8 @@ class DbEfficacyIndicatorTestCase(base.DbTestCase):
|
||||
def test_update_efficacy_indicator(self):
|
||||
efficacy_indicator = self._create_test_efficacy_indicator()
|
||||
res = self.dbapi.update_efficacy_indicator(
|
||||
efficacy_indicator.id, {'state': 'CANCELLED'})
|
||||
efficacy_indicator.id,
|
||||
{'state': objects.action_plan.State.CANCELLED})
|
||||
self.assertEqual('CANCELLED', res.state)
|
||||
|
||||
def test_update_efficacy_indicator_that_does_not_exist(self):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from watcher.db import api as db_api
|
||||
from watcher import objects
|
||||
|
||||
|
||||
def get_test_audit_template(**kwargs):
|
||||
@@ -97,7 +98,7 @@ def get_test_action(**kwargs):
|
||||
'key2': 'val2',
|
||||
'resource_id':
|
||||
'10a47dd1-4874-4298-91cf-eff046dbdb8d'}),
|
||||
'state': kwargs.get('state', 'PENDING'),
|
||||
'state': kwargs.get('state', objects.action_plan.State.PENDING),
|
||||
'next': kwargs.get('next', 2),
|
||||
'created_at': kwargs.get('created_at'),
|
||||
'updated_at': kwargs.get('updated_at'),
|
||||
@@ -124,7 +125,7 @@ def get_test_action_plan(**kwargs):
|
||||
return {
|
||||
'id': kwargs.get('id', 1),
|
||||
'uuid': kwargs.get('uuid', '76be87bd-3422-43f9-93a0-e85a577e3061'),
|
||||
'state': kwargs.get('state', 'ONGOING'),
|
||||
'state': kwargs.get('state', objects.action_plan.State.ONGOING),
|
||||
'audit_id': kwargs.get('audit_id', 1),
|
||||
'strategy_id': kwargs.get('strategy_id', 1),
|
||||
'global_efficacy': kwargs.get('global_efficacy', {}),
|
||||
|
||||
Reference in New Issue
Block a user