def test_timestamp_from_future(self): """Message from the future""" now = datetime.datetime.utcnow() timestamp = dt_to_ts(now + (self.mtd * 2) + one_second) with self.assertRaises(exceptions.MessageFromFutureError): message.verify_time(timestamp)
def test_ancient_timestamp(self): """Message too old""" now = datetime.datetime.utcnow() timestamp = dt_to_ts(now - (self.mtd * 2) - self.mmtt - (self.mat * 2) - one_second) with self.assertRaises(exceptions.MessageTooOldError): message.verify_time(timestamp)
def test_timestamp_within_range_middle(self): """Proper timestamp inside""" now = datetime.datetime.utcnow() timestamp = dt_to_ts(now) message.verify_time(timestamp)
def test_timestamp_within_range_high(self): """Proper timestamp high border""" now = datetime.datetime.utcnow() timestamp = dt_to_ts(now + (self.mtd * 2)) message.verify_time(timestamp)
def test_timestamp_within_range_low(self): """Proper timestamp low border""" now = datetime.datetime.utcnow() timestamp = dt_to_ts(now - (self.mtd * 2) - self.mmtt - (self.mat * 2)) message.verify_time(timestamp)