Mercurial > kallithea
comparison rhodecode/tests/test_libs.py @ 2317:c4d8ed624728 beta
Fixed tests for new i18n changes
- added new test for age function
- added new Contributor to RhodeCode
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 20 May 2012 14:34:45 +0200 |
parents | ea5ff843b200 |
children | a05e01144a2c |
comparison
equal
deleted
inserted
replaced
2316:14281c7d5c2f | 2317:c4d8ed624728 |
---|---|
21 # GNU General Public License for more details. | 21 # GNU General Public License for more details. |
22 # | 22 # |
23 # You should have received a copy of the GNU General Public License | 23 # You should have received a copy of the GNU General Public License |
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | 25 |
26 import unittest | |
27 import datetime | |
28 from rhodecode.tests import * | |
26 | 29 |
27 | |
28 import unittest | |
29 from rhodecode.tests import * | |
30 | 30 |
31 proto = 'http' | 31 proto = 'http' |
32 TEST_URLS = [ | 32 TEST_URLS = [ |
33 ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'], | 33 ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'], |
34 '%s://127.0.0.1' % proto), | 34 '%s://127.0.0.1' % proto), |
114 s = sorted([ | 114 s = sorted([ |
115 'first', 'marcink', 'lukaszb', 'one_more22', 'MARCIN', 'maRCiN', 'john', | 115 'first', 'marcink', 'lukaszb', 'one_more22', 'MARCIN', 'maRCiN', 'john', |
116 'marian.user', 'marco-polo', 'marco_polo' | 116 'marian.user', 'marco-polo', 'marco_polo' |
117 ], key=lambda k: k.lower()) | 117 ], key=lambda k: k.lower()) |
118 self.assertEqual(s, extract_mentioned_users(sample)) | 118 self.assertEqual(s, extract_mentioned_users(sample)) |
119 | |
120 def test_age(self): | |
121 from rhodecode.lib.utils2 import age | |
122 n = datetime.datetime.now() | |
123 delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs) | |
124 self.assertEqual(age(n), u'just now') | |
125 self.assertEqual(age(n - delt(seconds=1)), u'1 second ago') | |
126 self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago') | |
127 self.assertEqual(age(n - delt(hours=1)), u'1 hour ago') | |
128 self.assertEqual(age(n - delt(hours=24)), u'1 day ago') | |
129 self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago') | |
130 self.assertEqual(age(n - delt(hours=24 * 32)), u'1 month and 2 days ago') | |
131 self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago') |