def test_date_observed_in_range_str_gives_correct_json_representation(): test_before_time = time() test_after_time = time() + 30 # make sure timestamps are actually different formatted_before = format_timestamp(test_before_time) formatted_after = format_timestamp(test_after_time) _filter = DateObserved.in_range(test_before_time, test_after_time) expected = IN_RANGE.format("createdAt", formatted_before, formatted_after) assert str(_filter) == expected
def test_date_observed_on_same_day_str_gives_correct_json_representation(): test_time = time() test_date = datetime.utcfromtimestamp(test_time) start_time = datetime(test_date.year, test_date.month, test_date.day, 0, 0, 0) end_time = datetime(test_date.year, test_date.month, test_date.day, 23, 59, 59) formatted_before = format_datetime(start_time) formatted_after = format_datetime(end_time) _filter = DateObserved.on_same_day(test_time) expected = IN_RANGE.format("createdAt", formatted_before, formatted_after) assert str(_filter) == expected
def test_date_observed_on_or_before_str_gives_correct_json_representation(): test_time = time() formatted = format_timestamp(test_time) _filter = DateObserved.on_or_before(test_time) expected = ON_OR_BEFORE.format("createdAt", formatted) assert str(_filter) == expected
def test_date_observed_does_not_have_within_the_last_option(): assert not hasattr(DateObserved(), "within_the_last")
def test_date_observed_on_or_after_str_gives_correct_json_representation(): test_time = time() formatted = format_timestamp_with_microseconds(test_time) _filter = DateObserved.on_or_after(test_time) expected = ON_OR_AFTER.format("createdAt", formatted) assert str(_filter) == expected