Merge "Fix field type to audit_type"
This commit is contained in:
commit
b1c6ea71a4
@ -54,7 +54,7 @@ class AuditPostType(wtypes.Base):
|
||||
|
||||
audit_template_uuid = wtypes.wsattr(types.uuid, mandatory=True)
|
||||
|
||||
type = wtypes.wsattr(wtypes.text, mandatory=True)
|
||||
audit_type = wtypes.wsattr(wtypes.text, mandatory=True)
|
||||
|
||||
deadline = wtypes.wsattr(datetime.datetime, mandatory=False)
|
||||
|
||||
@ -66,12 +66,12 @@ class AuditPostType(wtypes.Base):
|
||||
|
||||
def as_audit(self):
|
||||
audit_type_values = [val.value for val in objects.audit.AuditType]
|
||||
if self.type not in audit_type_values:
|
||||
raise exception.AuditTypeNotFound(audit_type=self.type)
|
||||
if self.audit_type not in audit_type_values:
|
||||
raise exception.AuditTypeNotFound(audit_type=self.audit_type)
|
||||
|
||||
return Audit(
|
||||
audit_template_id=self.audit_template_uuid,
|
||||
type=self.type,
|
||||
audit_type=self.audit_type,
|
||||
deadline=self.deadline,
|
||||
parameters=self.parameters,
|
||||
)
|
||||
@ -133,7 +133,7 @@ class Audit(base.APIBase):
|
||||
uuid = types.uuid
|
||||
"""Unique UUID for this audit"""
|
||||
|
||||
type = wtypes.text
|
||||
audit_type = wtypes.text
|
||||
"""Type of this audit"""
|
||||
|
||||
deadline = datetime.datetime
|
||||
@ -185,7 +185,7 @@ class Audit(base.APIBase):
|
||||
@staticmethod
|
||||
def _convert_with_links(audit, url, expand=True):
|
||||
if not expand:
|
||||
audit.unset_fields_except(['uuid', 'type', 'deadline',
|
||||
audit.unset_fields_except(['uuid', 'audit_type', 'deadline',
|
||||
'state', 'audit_template_uuid',
|
||||
'audit_template_name'])
|
||||
|
||||
@ -210,7 +210,7 @@ class Audit(base.APIBase):
|
||||
@classmethod
|
||||
def sample(cls, expand=True):
|
||||
sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
state='PENDING',
|
||||
deadline=None,
|
||||
created_at=datetime.datetime.utcnow(),
|
||||
|
@ -330,7 +330,7 @@ class Connection(api.BaseConnection):
|
||||
if filters is None:
|
||||
filters = {}
|
||||
|
||||
plain_fields = ['uuid', 'type', 'state', 'audit_template_id']
|
||||
plain_fields = ['uuid', 'audit_type', 'state', 'audit_template_id']
|
||||
join_fieldmap = {
|
||||
'audit_template_uuid': ("uuid", models.AuditTemplate),
|
||||
'audit_template_name': ("name", models.AuditTemplate),
|
||||
|
@ -171,7 +171,7 @@ class Audit(Base):
|
||||
)
|
||||
id = Column(Integer, primary_key=True)
|
||||
uuid = Column(String(36))
|
||||
type = Column(String(20))
|
||||
audit_type = Column(String(20))
|
||||
state = Column(String(20), nullable=True)
|
||||
deadline = Column(DateTime, nullable=True)
|
||||
audit_template_id = Column(Integer, ForeignKey('audit_templates.id'),
|
||||
|
@ -81,7 +81,7 @@ class Audit(base.WatcherObject):
|
||||
fields = {
|
||||
'id': int,
|
||||
'uuid': obj_utils.str_or_none,
|
||||
'type': obj_utils.str_or_none,
|
||||
'audit_type': obj_utils.str_or_none,
|
||||
'state': obj_utils.str_or_none,
|
||||
'deadline': obj_utils.datetime_or_str_or_none,
|
||||
'audit_template_id': obj_utils.int_or_none,
|
||||
|
@ -75,7 +75,7 @@ class TestListAudit(api_base.FunctionalTest):
|
||||
self.assertEqual([], response['audits'])
|
||||
|
||||
def _assert_audit_fields(self, audit):
|
||||
audit_fields = ['type', 'deadline', 'state']
|
||||
audit_fields = ['audit_type', 'deadline', 'state']
|
||||
for field in audit_fields:
|
||||
self.assertIn(field, audit)
|
||||
|
||||
|
@ -107,9 +107,9 @@ class TestNovaHelper(base.TestCase):
|
||||
instance = mock.MagicMock(id=self.instance_uuid)
|
||||
setattr(instance, 'OS-EXT-SRV-ATTR:host', self.source_hypervisor)
|
||||
addresses = mock.MagicMock()
|
||||
type = mock.MagicMock()
|
||||
network_type = mock.MagicMock()
|
||||
networks = []
|
||||
networks.append(("lan", type))
|
||||
networks.append(("lan", network_type))
|
||||
addresses.items.return_value = networks
|
||||
attached_volumes = mock.MagicMock()
|
||||
setattr(instance, 'addresses', addresses)
|
||||
|
@ -252,7 +252,7 @@ class DbActionPlanTestCase(base.DbTestCase):
|
||||
def test_get_action_plan_list_with_filters(self):
|
||||
audit = self._create_test_audit(
|
||||
id=1,
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING')
|
||||
|
@ -267,23 +267,23 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
def test_get_audit_list_with_filters(self):
|
||||
audit1 = self._create_test_audit(
|
||||
id=1,
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING')
|
||||
audit2 = self._create_test_audit(
|
||||
id=2,
|
||||
type='CONTINUOUS',
|
||||
audit_type='CONTINUOUS',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='PENDING')
|
||||
|
||||
res = self.dbapi.get_audit_list(self.context,
|
||||
filters={'type': 'ONESHOT'})
|
||||
filters={'audit_type': 'ONESHOT'})
|
||||
self.assertEqual([audit1['id']], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_audit_list(self.context,
|
||||
filters={'type': 'bad-type'})
|
||||
filters={'audit_type': 'bad-type'})
|
||||
self.assertEqual([], [r.id for r in res])
|
||||
|
||||
res = self.dbapi.get_audit_list(
|
||||
@ -331,7 +331,7 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
)
|
||||
|
||||
audit = self._create_test_audit(
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING',
|
||||
@ -357,7 +357,7 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
)
|
||||
|
||||
audit = self._create_test_audit(
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
uuid=w_utils.generate_uuid(),
|
||||
deadline=None,
|
||||
state='ONGOING',
|
||||
|
@ -54,7 +54,7 @@ def get_test_audit(**kwargs):
|
||||
return {
|
||||
'id': kwargs.get('id', 1),
|
||||
'uuid': kwargs.get('uuid', '10a47dd1-4874-4298-91cf-eff046dbdb8d'),
|
||||
'type': kwargs.get('type', 'ONESHOT'),
|
||||
'audit_type': kwargs.get('audit_type', 'ONESHOT'),
|
||||
'state': kwargs.get('state'),
|
||||
'deadline': kwargs.get('deadline'),
|
||||
'audit_template_id': kwargs.get('audit_template_id', 1),
|
||||
|
@ -155,7 +155,7 @@ class BaseInfraOptimTest(test.BaseTestCase):
|
||||
# ### AUDITS ### #
|
||||
|
||||
@classmethod
|
||||
def create_audit(cls, audit_template_uuid, type='ONESHOT',
|
||||
def create_audit(cls, audit_template_uuid, audit_type='ONESHOT',
|
||||
state=None, deadline=None):
|
||||
"""Wrapper utility for creating a test audit
|
||||
|
||||
@ -166,7 +166,7 @@ class BaseInfraOptimTest(test.BaseTestCase):
|
||||
:return: A tuple with The HTTP response and its body
|
||||
"""
|
||||
resp, body = cls.client.create_audit(
|
||||
audit_template_uuid=audit_template_uuid, type=type,
|
||||
audit_template_uuid=audit_template_uuid, audit_type=audit_type,
|
||||
state=state, deadline=deadline)
|
||||
|
||||
cls.created_audits.add(body['uuid'])
|
||||
|
@ -41,7 +41,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
||||
|
||||
audit_params = dict(
|
||||
audit_template_uuid=audit_template['uuid'],
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
)
|
||||
|
||||
_, body = self.create_audit(**audit_params)
|
||||
@ -57,7 +57,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
||||
|
||||
audit_params = dict(
|
||||
audit_template_uuid=audit_template['uuid'],
|
||||
type='CONTINUOUS',
|
||||
audit_type='CONTINUOUS',
|
||||
)
|
||||
|
||||
_, body = self.create_audit(**audit_params)
|
||||
@ -70,7 +70,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
||||
def test_create_audit_with_wrong_audit_template(self):
|
||||
audit_params = dict(
|
||||
audit_template_uuid='INVALID',
|
||||
type='ONESHOT',
|
||||
audit_type='ONESHOT',
|
||||
)
|
||||
|
||||
self.assertRaises(
|
||||
|
@ -111,7 +111,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
|
||||
# ### AUDITS ### #
|
||||
|
||||
def create_audit(self, audit_template_uuid, type='ONESHOT',
|
||||
def create_audit(self, audit_template_uuid, audit_type='ONESHOT',
|
||||
state=None, deadline=None):
|
||||
"""Wrapper utility for creating a test audit
|
||||
|
||||
@ -120,7 +120,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
:return: A tuple with The HTTP response and its body
|
||||
"""
|
||||
resp, body = self.client.create_audit(
|
||||
audit_template_uuid=audit_template_uuid, type=type,
|
||||
audit_template_uuid=audit_template_uuid, audit_type=audit_type,
|
||||
state=state, deadline=deadline)
|
||||
|
||||
self.addCleanup(self.delete_audit, audit_uuid=body["uuid"])
|
||||
|
Loading…
Reference in New Issue
Block a user