Merge "Fix logic error in sqlarchemy api"

changes/20/490320/6
Zuul 5 years ago committed by Gerrit Code Review
commit 78a48ad4c4

@ -1316,12 +1316,14 @@ def service_get_all_by_args(context, host, binary, hostname):
def purge_deleted(age, granularity='days', project_id=None, batch_size=20):
def _validate_positive_integer(val, argname):
try:
return int(val)
val = int(val)
except ValueError:
raise exception.Error(_("%s should be an integer") % argname)
if val < 0:
raise exception.Error(_("%s should be a positive integer")
% argname)
return val
age = _validate_positive_integer(age, 'age')
batch_size = _validate_positive_integer(batch_size, 'batch_size')

@ -2018,6 +2018,9 @@ class DBAPIStackTest(common.HeatTestCase):
self._deleted_stack_existance(admin_ctx, stacks, resources,
events, tmpl_files, (), (0, 1, 2, 3, 4))
# test wrong age
self.assertRaises(exception.Error, db_api.purge_deleted, -1, 'seconds')
def test_purge_project_deleted(self):
now = timeutils.utcnow()
delta = datetime.timedelta(seconds=3600 * 7)

Loading…
Cancel
Save