コード例 #1
0
ファイル: test_helpers.py プロジェクト: phraniiac/allura
def test_ago():
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), '2 hours ago')
    d_str = (datetime.utcnow() - timedelta(hours=3)).isoformat()
    assert_equals(h.ago_string(d_str), '3 hours ago')
    assert_equals(h.ago_string('bad format'), 'unknown')
    assert_equals(h.ago_string(None), 'unknown')

    monthish = datetime.utcnow() - timedelta(days=32)
    assert 'ago' not in h.ago(monthish)
    assert_equals(h.ago(monthish, show_date_after=90), '1 month ago')
    assert_equals(h.ago(monthish, show_date_after=None), '1 month ago')
コード例 #2
0
def test_ago():
    from datetime import datetime, timedelta
    import time

    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), "2 days ago")
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), "2 hours ago")
    d_str = (datetime.utcnow() - timedelta(hours=3)).isoformat()
    assert_equals(h.ago_string(d_str), "3 hours ago")
    assert_equals(h.ago_string("bad format"), "unknown")
    assert_equals(h.ago_string(None), "unknown")

    monthish = datetime.utcnow() - timedelta(days=32)
    assert "ago" not in h.ago(monthish)
    assert_equals(h.ago(monthish, show_date_after=90), "1 month ago")
    assert_equals(h.ago(monthish, show_date_after=None), "1 month ago")
コード例 #3
0
def test_ago():
    from datetime import datetime, timedelta
    import time
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), '2 hours ago')
コード例 #4
0
 def time_since(self, *time_components):
     end_time = datetime(*time_components)
     with patch('allura.lib.helpers.datetime') as datetime_class:
         datetime_class.utcnow.return_value = end_time
         return helpers.ago(self.start_time)
コード例 #5
0
 def time_since(self, *time_components):
     end_time = datetime(*time_components)
     with patch('allura.lib.helpers.datetime') as datetime_class:
         datetime_class.utcnow.return_value = end_time
         return helpers.ago(self.start_time)
コード例 #6
0
 def summary(self):
     return '<a href="%s">%s</a> %s' % (
         self.author().url(), self.author().get_pref('display_name'),
         h.ago(self.timestamp))
コード例 #7
0
ファイル: test_helpers.py プロジェクト: Bitergia/allura
def test_ago():
    from datetime import datetime, timedelta
    import time
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60*60*2), '2 hours ago')
コード例 #8
0
 def summary(self):
     return '<a href="%s">%s</a> %s' % (
         self.author().url(), self.author().get_pref('display_name'),
         h.ago(self.timestamp))