Verified Commit cea393f9 authored by juga's avatar juga
Browse files

Merge branch 'm13'

parents 2c26ad87 64c22724
......@@ -38,7 +38,7 @@ class DateTimeSeq(collections.deque):
def last(self):
if len(self._items) > 0:
return self._items[-1]
return datetime.utcnow().replace(microsecond=0) - timedelta(hour=1)
return datetime.utcnow().replace(microsecond=0) - timedelta(hours=1)
def list(self):
return list(self._items)
......@@ -80,7 +80,7 @@ class DateTimeIntSeq(collections.deque):
def last(self):
if len(self._items) > 0:
return self._items[-1]
return datetime.utcnow().replace(microsecond=0) - timedelta(hour=1)
return datetime.utcnow().replace(microsecond=0) - timedelta(hours=1)
def list(self):
return list(self._items)
......
......@@ -39,3 +39,38 @@ def test_update_datetime_int_seq(conf):
assert 8 == state.count("recent_measurement_attempt")
# And `len` should return the same.
assert 8 == len(dt_seq)
def test_last_datetime_seq(conf):
dt_seq = DateTimeSeq([])
new_dts = dt_seq.last()
assert new_dts == datetime.utcnow().replace(microsecond=0) - timedelta(
hours=1
)
def test_create_list_datetime_seq(conf):
now = datetime.utcnow().replace(microsecond=0)
# Create a list of 6 datetimes that started 6 days in the past.
dts = [now - timedelta(days=x) for x in range(6, 0, -1)]
dt_seq = DateTimeSeq(dts)
new_dts = dt_seq.list()
assert type(new_dts) == list
def test_create_list_dt_int_seq(conf):
now = datetime.utcnow().replace(microsecond=0)
# Create a list of 6 datetimes that started 6 days in the past.
dts = [now - timedelta(days=x) for x in range(6, 0, -1)]
dt_int_seq = DateTimeIntSeq(dts)
new_dt_int_seq = dt_int_seq.list()
assert type(new_dt_int_seq) == list
def test_last_dt_int_seq(conf):
dt_seq = DateTimeIntSeq([])
assert (
datetime.utcnow().replace(microsecond=0) - timedelta(hours=1)
== dt_seq.last()
)
Supports Markdown
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