Пример #1
0
 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")
Пример #2
0
 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")
Пример #3
0
    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")
Пример #4
0
 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")
Пример #5
0
 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")
Пример #6
0
 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")