Fix field type to audit_type
There's a number of places where a field of an object is named "type", which isn't good thing. Actually type is keyword in python, so wherever I found type used in models/api/object/test, I have fixed it to audit_type in the audit files Change-Id: Iea6bd3acb0b2af2a833b3916701aad88f6064bba Closes-Bug: #1533392
This commit is contained in:
@@ -53,7 +53,7 @@ class AuditPostType(wtypes.Base):
|
|||||||
|
|
||||||
audit_template_uuid = wtypes.wsattr(types.uuid, mandatory=True)
|
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)
|
deadline = wtypes.wsattr(datetime.datetime, mandatory=False)
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ class AuditPostType(wtypes.Base):
|
|||||||
|
|
||||||
def as_audit(self):
|
def as_audit(self):
|
||||||
audit_type_values = [val.value for val in objects.audit.AuditType]
|
audit_type_values = [val.value for val in objects.audit.AuditType]
|
||||||
if self.type not in audit_type_values:
|
if self.audit_type not in audit_type_values:
|
||||||
raise exception.AuditTypeNotFound(audit_type=self.type)
|
raise exception.AuditTypeNotFound(audit_type=self.audit_type)
|
||||||
|
|
||||||
return Audit(
|
return Audit(
|
||||||
audit_template_id=self.audit_template_uuid,
|
audit_template_id=self.audit_template_uuid,
|
||||||
type=self.type,
|
audit_type=self.audit_type,
|
||||||
deadline=self.deadline,
|
deadline=self.deadline,
|
||||||
parameters=self.parameters,
|
parameters=self.parameters,
|
||||||
)
|
)
|
||||||
@@ -132,7 +132,7 @@ class Audit(base.APIBase):
|
|||||||
uuid = types.uuid
|
uuid = types.uuid
|
||||||
"""Unique UUID for this audit"""
|
"""Unique UUID for this audit"""
|
||||||
|
|
||||||
type = wtypes.text
|
audit_type = wtypes.text
|
||||||
"""Type of this audit"""
|
"""Type of this audit"""
|
||||||
|
|
||||||
deadline = datetime.datetime
|
deadline = datetime.datetime
|
||||||
@@ -184,7 +184,7 @@ class Audit(base.APIBase):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_with_links(audit, url, expand=True):
|
def _convert_with_links(audit, url, expand=True):
|
||||||
if not expand:
|
if not expand:
|
||||||
audit.unset_fields_except(['uuid', 'type', 'deadline',
|
audit.unset_fields_except(['uuid', 'audit_type', 'deadline',
|
||||||
'state', 'audit_template_uuid',
|
'state', 'audit_template_uuid',
|
||||||
'audit_template_name'])
|
'audit_template_name'])
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ class Audit(base.APIBase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def sample(cls, expand=True):
|
def sample(cls, expand=True):
|
||||||
sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
|
sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
state='PENDING',
|
state='PENDING',
|
||||||
deadline=None,
|
deadline=None,
|
||||||
created_at=datetime.datetime.utcnow(),
|
created_at=datetime.datetime.utcnow(),
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ class Connection(api.BaseConnection):
|
|||||||
if filters is None:
|
if filters is None:
|
||||||
filters = {}
|
filters = {}
|
||||||
|
|
||||||
plain_fields = ['uuid', 'type', 'state', 'audit_template_id']
|
plain_fields = ['uuid', 'audit_type', 'state', 'audit_template_id']
|
||||||
join_fieldmap = {
|
join_fieldmap = {
|
||||||
'audit_template_uuid': ("uuid", models.AuditTemplate),
|
'audit_template_uuid': ("uuid", models.AuditTemplate),
|
||||||
'audit_template_name': ("name", models.AuditTemplate),
|
'audit_template_name': ("name", models.AuditTemplate),
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class Audit(Base):
|
|||||||
)
|
)
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
uuid = Column(String(36))
|
uuid = Column(String(36))
|
||||||
type = Column(String(20))
|
audit_type = Column(String(20))
|
||||||
state = Column(String(20), nullable=True)
|
state = Column(String(20), nullable=True)
|
||||||
deadline = Column(DateTime, nullable=True)
|
deadline = Column(DateTime, nullable=True)
|
||||||
audit_template_id = Column(Integer, ForeignKey('audit_templates.id'),
|
audit_template_id = Column(Integer, ForeignKey('audit_templates.id'),
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class Audit(base.WatcherObject):
|
|||||||
fields = {
|
fields = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'uuid': obj_utils.str_or_none,
|
'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,
|
'state': obj_utils.str_or_none,
|
||||||
'deadline': obj_utils.datetime_or_str_or_none,
|
'deadline': obj_utils.datetime_or_str_or_none,
|
||||||
'audit_template_id': obj_utils.int_or_none,
|
'audit_template_id': obj_utils.int_or_none,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class TestListAudit(api_base.FunctionalTest):
|
|||||||
self.assertEqual([], response['audits'])
|
self.assertEqual([], response['audits'])
|
||||||
|
|
||||||
def _assert_audit_fields(self, audit):
|
def _assert_audit_fields(self, audit):
|
||||||
audit_fields = ['type', 'deadline', 'state']
|
audit_fields = ['audit_type', 'deadline', 'state']
|
||||||
for field in audit_fields:
|
for field in audit_fields:
|
||||||
self.assertIn(field, audit)
|
self.assertIn(field, audit)
|
||||||
|
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ class TestNovaHelper(base.TestCase):
|
|||||||
instance = mock.MagicMock(id=self.instance_uuid)
|
instance = mock.MagicMock(id=self.instance_uuid)
|
||||||
setattr(instance, 'OS-EXT-SRV-ATTR:host', self.source_hypervisor)
|
setattr(instance, 'OS-EXT-SRV-ATTR:host', self.source_hypervisor)
|
||||||
addresses = mock.MagicMock()
|
addresses = mock.MagicMock()
|
||||||
type = mock.MagicMock()
|
network_type = mock.MagicMock()
|
||||||
networks = []
|
networks = []
|
||||||
networks.append(("lan", type))
|
networks.append(("lan", network_type))
|
||||||
addresses.items.return_value = networks
|
addresses.items.return_value = networks
|
||||||
attached_volumes = mock.MagicMock()
|
attached_volumes = mock.MagicMock()
|
||||||
setattr(instance, 'addresses', addresses)
|
setattr(instance, 'addresses', addresses)
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class DbActionPlanTestCase(base.DbTestCase):
|
|||||||
def test_get_action_plan_list_with_filters(self):
|
def test_get_action_plan_list_with_filters(self):
|
||||||
audit = self._create_test_audit(
|
audit = self._create_test_audit(
|
||||||
id=1,
|
id=1,
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
uuid=w_utils.generate_uuid(),
|
uuid=w_utils.generate_uuid(),
|
||||||
deadline=None,
|
deadline=None,
|
||||||
state='ONGOING')
|
state='ONGOING')
|
||||||
|
|||||||
@@ -267,23 +267,23 @@ class DbAuditTestCase(base.DbTestCase):
|
|||||||
def test_get_audit_list_with_filters(self):
|
def test_get_audit_list_with_filters(self):
|
||||||
audit1 = self._create_test_audit(
|
audit1 = self._create_test_audit(
|
||||||
id=1,
|
id=1,
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
uuid=w_utils.generate_uuid(),
|
uuid=w_utils.generate_uuid(),
|
||||||
deadline=None,
|
deadline=None,
|
||||||
state='ONGOING')
|
state='ONGOING')
|
||||||
audit2 = self._create_test_audit(
|
audit2 = self._create_test_audit(
|
||||||
id=2,
|
id=2,
|
||||||
type='CONTINUOUS',
|
audit_type='CONTINUOUS',
|
||||||
uuid=w_utils.generate_uuid(),
|
uuid=w_utils.generate_uuid(),
|
||||||
deadline=None,
|
deadline=None,
|
||||||
state='PENDING')
|
state='PENDING')
|
||||||
|
|
||||||
res = self.dbapi.get_audit_list(self.context,
|
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])
|
self.assertEqual([audit1['id']], [r.id for r in res])
|
||||||
|
|
||||||
res = self.dbapi.get_audit_list(self.context,
|
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])
|
self.assertEqual([], [r.id for r in res])
|
||||||
|
|
||||||
res = self.dbapi.get_audit_list(
|
res = self.dbapi.get_audit_list(
|
||||||
@@ -331,7 +331,7 @@ class DbAuditTestCase(base.DbTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
audit = self._create_test_audit(
|
audit = self._create_test_audit(
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
uuid=w_utils.generate_uuid(),
|
uuid=w_utils.generate_uuid(),
|
||||||
deadline=None,
|
deadline=None,
|
||||||
state='ONGOING',
|
state='ONGOING',
|
||||||
@@ -357,7 +357,7 @@ class DbAuditTestCase(base.DbTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
audit = self._create_test_audit(
|
audit = self._create_test_audit(
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
uuid=w_utils.generate_uuid(),
|
uuid=w_utils.generate_uuid(),
|
||||||
deadline=None,
|
deadline=None,
|
||||||
state='ONGOING',
|
state='ONGOING',
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ def get_test_audit(**kwargs):
|
|||||||
return {
|
return {
|
||||||
'id': kwargs.get('id', 1),
|
'id': kwargs.get('id', 1),
|
||||||
'uuid': kwargs.get('uuid', '10a47dd1-4874-4298-91cf-eff046dbdb8d'),
|
'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'),
|
'state': kwargs.get('state'),
|
||||||
'deadline': kwargs.get('deadline'),
|
'deadline': kwargs.get('deadline'),
|
||||||
'audit_template_id': kwargs.get('audit_template_id', 1),
|
'audit_template_id': kwargs.get('audit_template_id', 1),
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class BaseInfraOptimTest(test.BaseTestCase):
|
|||||||
# ### AUDITS ### #
|
# ### AUDITS ### #
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_audit(cls, audit_template_uuid, type='ONESHOT',
|
def create_audit(cls, audit_template_uuid, audit_type='ONESHOT',
|
||||||
state=None, deadline=None):
|
state=None, deadline=None):
|
||||||
"""Wrapper utility for creating a test audit
|
"""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
|
:return: A tuple with The HTTP response and its body
|
||||||
"""
|
"""
|
||||||
resp, body = cls.client.create_audit(
|
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)
|
state=state, deadline=deadline)
|
||||||
|
|
||||||
cls.created_audits.add(body['uuid'])
|
cls.created_audits.add(body['uuid'])
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
|||||||
|
|
||||||
audit_params = dict(
|
audit_params = dict(
|
||||||
audit_template_uuid=audit_template['uuid'],
|
audit_template_uuid=audit_template['uuid'],
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
)
|
)
|
||||||
|
|
||||||
_, body = self.create_audit(**audit_params)
|
_, body = self.create_audit(**audit_params)
|
||||||
@@ -57,7 +57,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
|||||||
|
|
||||||
audit_params = dict(
|
audit_params = dict(
|
||||||
audit_template_uuid=audit_template['uuid'],
|
audit_template_uuid=audit_template['uuid'],
|
||||||
type='CONTINUOUS',
|
audit_type='CONTINUOUS',
|
||||||
)
|
)
|
||||||
|
|
||||||
_, body = self.create_audit(**audit_params)
|
_, body = self.create_audit(**audit_params)
|
||||||
@@ -70,7 +70,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest):
|
|||||||
def test_create_audit_with_wrong_audit_template(self):
|
def test_create_audit_with_wrong_audit_template(self):
|
||||||
audit_params = dict(
|
audit_params = dict(
|
||||||
audit_template_uuid='INVALID',
|
audit_template_uuid='INVALID',
|
||||||
type='ONESHOT',
|
audit_type='ONESHOT',
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class TestCreateDeleteAuditTemplate(base.BaseInfraOptimTest):
|
|||||||
|
|
||||||
@test.attr(type='smoke')
|
@test.attr(type='smoke')
|
||||||
def test_create_audit_template_unicode_description(self):
|
def test_create_audit_template_unicode_description(self):
|
||||||
goal_name = "DUMMY"
|
goal_name = "dummy"
|
||||||
_, goal = self.client.show_goal(goal_name)
|
_, goal = self.client.show_goal(goal_name)
|
||||||
# Use a unicode string for testing:
|
# Use a unicode string for testing:
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
|||||||
|
|
||||||
# ### AUDITS ### #
|
# ### AUDITS ### #
|
||||||
|
|
||||||
def create_audit(self, audit_template_uuid, type='ONESHOT',
|
def create_audit(self, audit_template_uuid, audit_type='ONESHOT',
|
||||||
state=None, deadline=None):
|
state=None, deadline=None):
|
||||||
"""Wrapper utility for creating a test audit
|
"""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
|
:return: A tuple with The HTTP response and its body
|
||||||
"""
|
"""
|
||||||
resp, body = self.client.create_audit(
|
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)
|
state=state, deadline=deadline)
|
||||||
|
|
||||||
self.addCleanup(self.delete_audit, audit_uuid=body["uuid"])
|
self.addCleanup(self.delete_audit, audit_uuid=body["uuid"])
|
||||||
|
|||||||
Reference in New Issue
Block a user