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_greater_equal_operator(self):
assert str(GreaterEqualOperator("uptime_days", 3))\
== '[">=", "uptime_days", 3]'
assert str(GreaterEqualOperator(
"start_time",
"2016-05-11T23:53:29.962Z"))\
== '[">=", "start_time", "2016-05-11T23:53:29.962Z"]'
assert str(GreaterEqualOperator(['parameter', 'version'], 4.0))\
== '[">=", ["parameter", "version"], 4.0]'
assert str(GreaterEqualOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '[">=", "report_timestamp", "2016-06-11 00:00:00"]'
def test_greater_equal_operator(self):
assert str(GreaterEqualOperator("uptime_days", 3))\
== '[">=", "uptime_days", 3]'
assert str(GreaterEqualOperator(
"start_time",
"2016-05-11T23:53:29.962Z"))\
== '[">=", "start_time", "2016-05-11T23:53:29.962Z"]'
assert str(GreaterEqualOperator(['parameter', 'version'], 4.0))\
== '[">=", ["parameter", "version"], 4.0]'
assert str(GreaterEqualOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '[">=", "report_timestamp", "2016-06-11 00:00:00"]'
def test_greater_equal_operator(self):
assert str(GreaterEqualOperator("uptime_days", 3))\
== '[">=", "uptime_days", 3]'
assert str(GreaterEqualOperator(
"start_time",
"2016-05-11T23:53:29.962Z"))\
== '[">=", "start_time", "2016-05-11T23:53:29.962Z"]'
assert str(GreaterEqualOperator(['parameter', 'version'], 4.0))\
== '[">=", ["parameter", "version"], 4.0]'
assert str(GreaterEqualOperator("report_timestamp",
datetime.datetime(2016, 6, 11)))\
== '[">=", "report_timestamp", "2016-06-11 00:00:00"]'
def test_greater_equal_operator(self):
assert str(GreaterEqualOperator("uptime_days", 3))\
== '[">=", "uptime_days", 3]'
assert str(GreaterEqualOperator(
"start_time",
"2016-05-11T23:53:29.962Z"))\
== '[">=", "start_time", "2016-05-11T23:53:29.962Z"]'
assert str(GreaterEqualOperator(['parameter', 'version'], 4.0))\
== '[">=", ["parameter", "version"], 4.0]'
assert str(GreaterEqualOperator("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(GreaterEqualOperator, self).__init__(">=", field, value)