Show More
@@ -123,15 +123,16 b' class TestLibs(unittest.TestCase):' | |||||
123 | from rhodecode.lib.utils2 import age |
|
123 | from rhodecode.lib.utils2 import age | |
124 | n = datetime.datetime.now() |
|
124 | n = datetime.datetime.now() | |
125 | delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs) |
|
125 | delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs) | |
|
126 | prev_month = n.month - 1 if n.month != 1 else n.month - 2 | |||
126 | self.assertEqual(age(n), u'just now') |
|
127 | self.assertEqual(age(n), u'just now') | |
127 | self.assertEqual(age(n - delt(seconds=1)), u'1 second ago') |
|
128 | self.assertEqual(age(n - delt(seconds=1)), u'1 second ago') | |
128 | self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago') |
|
129 | self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago') | |
129 | self.assertEqual(age(n - delt(hours=1)), u'1 hour ago') |
|
130 | self.assertEqual(age(n - delt(hours=1)), u'1 hour ago') | |
130 | self.assertEqual(age(n - delt(hours=24)), u'1 day ago') |
|
131 | self.assertEqual(age(n - delt(hours=24)), u'1 day ago') | |
131 | self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago') |
|
132 | self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago') | |
132 |
self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[ |
|
133 | self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[prev_month]))), | |
133 | u'1 month ago') |
|
134 | u'1 month ago') | |
134 |
self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[ |
|
135 | self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[prev_month] + 2))), | |
135 | u'1 month and 2 days ago') |
|
136 | u'1 month and 2 days ago') | |
136 | self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago') |
|
137 | self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago') | |
137 |
|
138 |
General Comments 0
You need to be logged in to leave comments.
Login now