Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_less_operator(self):
assert str(LessOperator("uptime_seconds", 300))\
== '["<", "uptime_seconds", 300]'
assert str(LessOperator(
"producer_timestamp",
"2016-05-11T23:53:29.962Z"))\
== '["<", "producer_timestamp", "2016-05-11T23:53:29.962Z"]'
assert str(LessOperator(['parameter', 'version'], 4.0))\
== '["<", ["parameter", "version"], 4.0]'
assert str(LessOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '["<", "report_timestamp", "2016-06-11 00:00:00"]'
def test_less_operator(self):
assert str(LessOperator("uptime_seconds", 300))\
== '["<", "uptime_seconds", 300]'
assert str(LessOperator(
"producer_timestamp",
"2016-05-11T23:53:29.962Z"))\
== '["<", "producer_timestamp", "2016-05-11T23:53:29.962Z"]'
assert str(LessOperator(['parameter', 'version'], 4.0))\
== '["<", ["parameter", "version"], 4.0]'
assert str(LessOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '["<", "report_timestamp", "2016-06-11 00:00:00"]'
def test_less_operator(self):
assert str(LessOperator("uptime_seconds", 300))\
== '["<", "uptime_seconds", 300]'
assert str(LessOperator(
"producer_timestamp",
"2016-05-11T23:53:29.962Z"))\
== '["<", "producer_timestamp", "2016-05-11T23:53:29.962Z"]'
assert str(LessOperator(['parameter', 'version'], 4.0))\
== '["<", ["parameter", "version"], 4.0]'
assert str(LessOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '["<", "report_timestamp", "2016-06-11 00:00:00"]'
def test_less_operator(self):
assert str(LessOperator("uptime_seconds", 300))\
== '["<", "uptime_seconds", 300]'
assert str(LessOperator(
"producer_timestamp",
"2016-05-11T23:53:29.962Z"))\
== '["<", "producer_timestamp", "2016-05-11T23:53:29.962Z"]'
assert str(LessOperator(['parameter', 'version'], 4.0))\
== '["<", ["parameter", "version"], 4.0]'
assert str(LessOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '["<", "report_timestamp", "2016-06-11 00:00:00"]'
def _build_query(env, start, end, certname=None):
"""Build a extract query with optional certname and environment."""
query = ExtractOperator()
query.add_field(FunctionOperator('count'))
query.add_field('status')
subquery = AndOperator()
subquery.add(GreaterEqualOperator('producer_timestamp', start))
subquery.add(LessOperator('producer_timestamp', end))
if certname is not None:
subquery.add(EqualsOperator('certname', certname))
if env != '*':
subquery.add(EqualsOperator('environment', env))
query.add_query(subquery)
query.add_group_by("status")
return query
def __init__(self, field, value):
super(LessOperator, self).__init__("<", field, value)