# HG changeset patch # User Marcin Kuzminski # Date 2012-05-20 12:34:45 # Node ID c4d8ed6247288faef2bf436f7eb0a7ca25480032 # Parent 14281c7d5c2f50741708256801cd72bf7eeeac7a Fixed tests for new i18n changes - added new test for age function - added new Contributor to RhodeCode diff --git a/CONTRIBUTORS b/CONTRIBUTORS --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -18,4 +18,5 @@ List of contributors to RhodeCode projec Aras Pranckevicius Tony Bussieres Erwin Kroon - nansenat16 \ No newline at end of file + nansenat16 + Vincent Duvert \ No newline at end of file diff --git a/rhodecode/tests/functional/test_changeset_comments.py b/rhodecode/tests/functional/test_changeset_comments.py --- a/rhodecode/tests/functional/test_changeset_comments.py +++ b/rhodecode/tests/functional/test_changeset_comments.py @@ -40,8 +40,8 @@ class TestChangeSetCommentsController(Te repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) - self.assertTrue('''
%s ''' - '''comment(s) (0 inline)
''' % 1 in response.body) + response.mustcontain('''
%s comment ''' + '''(0 inline)
''' % 1) self.assertEqual(Notification.query().count(), 1) self.assertEqual(ChangesetComment.query().count(), 1) @@ -76,7 +76,7 @@ class TestChangeSetCommentsController(Te #test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain( - '''
0 comment(s)''' + '''
0 comments''' ''' (%s inline)
''' % 1 ) response.mustcontain( @@ -115,8 +115,8 @@ class TestChangeSetCommentsController(Te repo_name=HG_REPO, revision=rev)) # test DB self.assertEqual(ChangesetComment.query().count(), 1) - self.assertTrue('''
%s ''' - '''comment(s) (0 inline)
''' % 1 in response.body) + response.mustcontain('''
%s ''' + '''comment (0 inline)
''' % 1) self.assertEqual(Notification.query().count(), 2) users = [x.user.username for x in UserNotification.query().all()] @@ -148,5 +148,5 @@ class TestChangeSetCommentsController(Te response = self.app.get(url(controller='changeset', action='index', repo_name=HG_REPO, revision=rev)) - self.assertTrue('''
0 comment(s)''' - ''' (0 inline)
''' in response.body) + response.mustcontain('''
0 comments''' + ''' (0 inline)
''') diff --git a/rhodecode/tests/test_libs.py b/rhodecode/tests/test_libs.py --- a/rhodecode/tests/test_libs.py +++ b/rhodecode/tests/test_libs.py @@ -23,10 +23,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - +import unittest +import datetime +from rhodecode.tests import * -import unittest -from rhodecode.tests import * proto = 'http' TEST_URLS = [ @@ -116,3 +116,16 @@ class TestLibs(unittest.TestCase): 'marian.user', 'marco-polo', 'marco_polo' ], key=lambda k: k.lower()) self.assertEqual(s, extract_mentioned_users(sample)) + + def test_age(self): + from rhodecode.lib.utils2 import age + n = datetime.datetime.now() + delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs) + self.assertEqual(age(n), u'just now') + self.assertEqual(age(n - delt(seconds=1)), u'1 second ago') + self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago') + self.assertEqual(age(n - delt(hours=1)), u'1 hour ago') + self.assertEqual(age(n - delt(hours=24)), u'1 day ago') + self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago') + self.assertEqual(age(n - delt(hours=24 * 32)), u'1 month and 2 days ago') + self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago')