def test_on_or_before(self, timestamp): expected = { "filterClause": "AND", "filters": [ { "operator": "ON_OR_BEFORE", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.000Z", } ], } assert dict(QueryFilterTimestampField.on_or_before(timestamp)) == expected
def test_on_or_before_with_decimals(self): filter_query = { "filterClause": "AND", "filters": [{ "operator": "ON_OR_BEFORE", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.123Z", }], } assert (dict(QueryFilterTimestampField.on_or_before(1599736333.123456)) == filter_query)
def test_on_or_after_with_decimals(self): filter_query = { "filterClause": "AND", "filters": [{ "operator": "ON_OR_AFTER", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.123Z", }], } qf = QueryFilterTimestampField.on_or_after(1599736333.123456) assert dict(qf) == filter_query
def test_on_or_after(self, timestamp): filter_query = { "filterClause": "AND", "filters": [{ "operator": "ON_OR_AFTER", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.000Z", }], } qf = QueryFilterTimestampField.on_or_after(timestamp) assert dict(qf) == filter_query
def test_on_same_day(self, timestamp): expected = { "filterClause": "AND", "filters": [ { "operator": "ON_OR_AFTER", "term": "override_timestamp_field_name", "value": "2020-09-10T00:00:00.000Z", }, { "operator": "ON_OR_BEFORE", "term": "override_timestamp_field_name", "value": "2020-09-10T23:59:59.000Z", }, ], } assert dict(QueryFilterTimestampField.on_same_day(timestamp)) == expected
def test_in_range_with_decimals(self): expected = { "filterClause": "AND", "filters": [ { "operator": "ON_OR_AFTER", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.123Z", }, { "operator": "ON_OR_BEFORE", "term": "override_timestamp_field_name", "value": "2020-09-10T12:13:14.678Z", }, ], } assert ( dict(QueryFilterTimestampField.in_range(1599736333.123456, 1599739994.6789)) == expected )
def test_in_range(self, start_timestamp, end_timestamp): expected = { "filterClause": "AND", "filters": [ { "operator": "ON_OR_AFTER", "term": "override_timestamp_field_name", "value": "2020-09-10T11:12:13.000Z", }, { "operator": "ON_OR_BEFORE", "term": "override_timestamp_field_name", "value": "2020-09-10T12:13:14.000Z", }, ], } assert ( dict(QueryFilterTimestampField.in_range(start_timestamp, end_timestamp)) == expected )