def test_format_age(self):
        assert format_age(datetime.utcnow() - timedelta(seconds = 5)) == 'just now'
        assert format_age(datetime.utcnow() - timedelta(minutes = 1)) == '1 minute ago'
        assert format_age(datetime.utcnow() - timedelta(minutes = 5)) == '5 minutes ago'
        assert format_age(datetime.utcnow() - timedelta(minutes = 60)) == '1 hour ago'
        assert format_age(datetime.utcnow() - timedelta(hours = 8)) == '8 hours ago'
        assert format_age(datetime.utcnow() - timedelta(days = 1)) == 'yesterday'
        assert format_age(datetime.utcnow() - timedelta(days = 3)) == '3 days ago'

        last_month = datetime.utcnow() - timedelta(days=28)
        assert format_age(last_month) == format_date(last_month)
Beispiel #2
0
    def test_format_age(self):
        assert format_age(datetime.utcnow() -
                          timedelta(seconds=5)) == 'just now'
        assert format_age(datetime.utcnow() -
                          timedelta(minutes=1)) == '1 minute ago'
        assert format_age(datetime.utcnow() -
                          timedelta(minutes=5)) == '5 minutes ago'
        assert format_age(datetime.utcnow() -
                          timedelta(minutes=60)) == '1 hour ago'
        assert format_age(datetime.utcnow() -
                          timedelta(hours=8)) == '8 hours ago'
        assert format_age(datetime.utcnow() - timedelta(days=1)) == 'yesterday'
        assert format_age(datetime.utcnow() -
                          timedelta(days=3)) == '3 days ago'

        last_month = datetime.utcnow() - timedelta(days=28)
        assert format_age(last_month) == format_date(last_month)
 def test_format_date(self):
     assert format_date(datetime(2011, 5, 1)) == 'May 1, 2011'
     assert format_date(datetime(2011, 5, 12)) == 'May 12, 2011'
     assert format_date(datetime(2011, 5, 12), format='%Y') == '2011'
Beispiel #4
0
 def test_format_date(self):
     assert format_date(datetime(2011, 5, 1)) == 'May 1, 2011'
     assert format_date(datetime(2011, 5, 12)) == 'May 12, 2011'
     assert format_date(datetime(2011, 5, 12), format='%Y') == '2011'