Merge "Fixes the use of dates when listing images"
This commit is contained in:
commit
3adf8cc6dd
@ -44,6 +44,7 @@ import six
|
||||
from webob import exc
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import timeutils
|
||||
from glance.i18n import _, _LE, _LW
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -603,8 +604,17 @@ def split_filter_op(expression):
|
||||
"""
|
||||
left, sep, right = expression.partition(':')
|
||||
if sep:
|
||||
op = left
|
||||
threshold = right
|
||||
# If the expression is a date of the format ISO 8601 like
|
||||
# CCYY-MM-DDThh:mm:ss+hh:mm and has no operator, it should
|
||||
# not be partitioned, and a default operator of eq should be
|
||||
# assumed.
|
||||
try:
|
||||
timeutils.parse_isotime(expression)
|
||||
op = 'eq'
|
||||
threshold = expression
|
||||
except ValueError:
|
||||
op = left
|
||||
threshold = right
|
||||
else:
|
||||
op = 'eq' # default operator
|
||||
threshold = left
|
||||
|
@ -450,6 +450,16 @@ class SplitFilterOpTestCase(test_utils.BaseTestCase):
|
||||
returned = utils.split_filter_op(expr)
|
||||
self.assertEqual(('eq', expr), returned)
|
||||
|
||||
def test_default_operator_with_datetime(self):
|
||||
expr = '2015-08-27T09:49:58Z'
|
||||
returned = utils.split_filter_op(expr)
|
||||
self.assertEqual(('eq', expr), returned)
|
||||
|
||||
def test_operator_with_datetime(self):
|
||||
expr = 'lt:2015-08-27T09:49:58Z'
|
||||
returned = utils.split_filter_op(expr)
|
||||
self.assertEqual(('lt', '2015-08-27T09:49:58Z'), returned)
|
||||
|
||||
|
||||
class EvaluateFilterOpTestCase(test_utils.BaseTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user