GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still and

Commit feae0a57 authored by juga  's avatar juga
Browse files

fix: tests: Add test timestamp.is_old

The tests don't pass in this commit, it's fixed in the next ones.
parent 6f740b6d
# -*- coding: utf-8 -*-
"""Test timestamp conversion util functions"""
from datetime import datetime, timezone
from datetime import datetime, timezone, timedelta
from sbws.util.timestamp import (dt_obj_to_isodt_str, unixts_to_dt_obj,
unixts_to_isodt_str, unixts_to_str)
unixts_to_isodt_str, unixts_to_str, is_old)
isodt_str = '2018-05-23T12:55:04'
......@@ -25,3 +24,14 @@ def test_unixts_to_isodt_str():
def test_unixts_to_str():
assert str(unixts) == unixts_to_str(unixts)
def test_is_old():
# Since this timestamp is generated a few microseconds before checking
# the oldest timestamp, it will be old.
old_timestamp = datetime.utcnow() - timedelta(days=5)
assert is_old(old_timestamp)
# A recent timestamp should be at least 1 second newer that the oldest
recent_timestamp = datetime.utcnow() - timedelta(days=5) \
+ timedelta(seconds=1)
assert not is_old(recent_timestamp)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment