def test_1_day(self): from api.models import Message message = Message() dt = datetime.datetime.fromtimestamp(time.time() - 3600 * 25) message.date = dt age = message.get_age() self.assertEqual(age, "1 day")
def test_now(self): from api.models import Message message = Message() dt = datetime.datetime.fromtimestamp(time.time() + 100) message.date = dt age = message.get_age() self.assertEqual(age, "now")
def test_0_second(self): from api.models import Message message = Message() message.date = datetime.datetime.utcnow() age = message.get_age() self.assertEqual(age, "0 second")