Add strategy_id & goal_id fields in audit template
In this changeset, I updated the 'goal_id' field into the AuditTemplate to now become a mandatory foreign key towards the Goal model. I also added the 'strategy_id' field into the AuditTemplate model to be an optional foreign key onto the Strategy model. This changeset also includes an update of the /audit_template Watcher API endpoint to reflect the previous changes. As this changeset changes the API, this should be merged alongside the related changeset from python-watcherclient. Partially Implements: blueprint get-goal-from-strategy Change-Id: Ic0573d036d1bbd7820f8eb963e47912d6b3ed1a9
This commit is contained in:
@@ -30,7 +30,8 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
||||
def test_JSONEncodedDict_default_value(self):
|
||||
# Create audit_template w/o extra
|
||||
audit_template1_id = w_utils.generate_uuid()
|
||||
self.dbapi.create_audit_template({'uuid': audit_template1_id})
|
||||
self.dbapi.create_audit_template({'uuid': audit_template1_id,
|
||||
'goal_id': "DUMMY"})
|
||||
audit_template1 = sa_api.model_query(models.AuditTemplate) \
|
||||
.filter_by(uuid=audit_template1_id).one()
|
||||
self.assertEqual({}, audit_template1.extra)
|
||||
@@ -39,6 +40,7 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
||||
# Create audit_template with extra
|
||||
audit_template2_id = w_utils.generate_uuid()
|
||||
self.dbapi.create_audit_template({'uuid': audit_template2_id,
|
||||
'goal_id': "DUMMY",
|
||||
'extra': {'bar': 'foo'}})
|
||||
audit_template2 = sa_api.model_query(models.AuditTemplate) \
|
||||
.filter_by(uuid=audit_template2_id).one()
|
||||
@@ -48,24 +50,3 @@ class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
|
||||
self.assertRaises(db_exc.DBError,
|
||||
self.dbapi.create_audit_template,
|
||||
{'extra': ['this is not a dict']})
|
||||
|
||||
# def test_JSONEncodedList_default_value(self):
|
||||
# # Create audit_template w/o images
|
||||
# audit_template1_id = w_utils.generate_uuid()
|
||||
# self.dbapi.create_audit_template({'uuid': audit_template1_id})
|
||||
# audit_template1 = sa_api.model_query(models.AuditTemplate) \
|
||||
# .filter_by(uuid=audit_template1_id).one()
|
||||
# self.assertEqual([], audit_template1.images)
|
||||
|
||||
# # Create audit_template with images
|
||||
# audit_template2_id = w_utils.generate_uuid()
|
||||
# self.dbapi.create_audit_template({'uuid': audit_template2_id,
|
||||
# 'images': ['myimage1', 'myimage2']})
|
||||
# audit_template2 = sa_api.model_query(models.AuditTemplate) \
|
||||
# .filter_by(uuid=audit_template2_id).one()
|
||||
# self.assertEqual(['myimage1', 'myimage2'], audit_template2.images)
|
||||
|
||||
# def test_JSONEncodedList_type_check(self):
|
||||
# self.assertRaises(db_exc.DBError,
|
||||
# self.dbapi.create_audit_template,
|
||||
# {'images': {'this is not a list': 'test'}})
|
||||
|
||||
@@ -21,7 +21,8 @@ def get_test_audit_template(**kwargs):
|
||||
return {
|
||||
'id': kwargs.get('id', 1),
|
||||
'uuid': kwargs.get('uuid', 'e74c40e0-d825-11e2-a28f-0800200c9a66'),
|
||||
'goal': kwargs.get('goal', 'DUMMY'),
|
||||
'goal_id': kwargs.get('goal_id', 1),
|
||||
'strategy_id': kwargs.get('strategy_id', None),
|
||||
'name': kwargs.get('name', 'My Audit Template'),
|
||||
'description': kwargs.get('description', 'Desc. Of My Audit Template'),
|
||||
'extra': kwargs.get('extra', {'automatic': False}),
|
||||
|
||||
Reference in New Issue
Block a user