##// END OF EJS Templates
fixed gravatar tests
marcink -
r3913:5f192af1 beta
parent child Browse files
Show More
@@ -1,294 +1,294 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.tests.test_libs
3 rhodecode.tests.test_libs
4 ~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6
6
7 Package for testing various lib/helper functions in rhodecode
7 Package for testing various lib/helper functions in rhodecode
8
8
9 :created_on: Jun 9, 2011
9 :created_on: Jun 9, 2011
10 :copyright: (C) 2011-2012 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2011-2012 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
11 :license: GPLv3, see COPYING for more details.
12 """
12 """
13 # This program is free software: you can redistribute it and/or modify
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
16 # (at your option) any later version.
17 #
17 #
18 # This program is distributed in the hope that it will be useful,
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 from __future__ import with_statement
25 from __future__ import with_statement
26 import datetime
26 import datetime
27 import hashlib
27 import hashlib
28 import mock
28 import mock
29 from rhodecode.tests import *
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),
35 ('%s://marcink@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
35 ('%s://marcink@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
36 '%s://127.0.0.1' % proto),
36 '%s://127.0.0.1' % proto),
37 ('%s://marcink:pass@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
37 ('%s://marcink:pass@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
38 '%s://127.0.0.1' % proto),
38 '%s://127.0.0.1' % proto),
39 ('%s://127.0.0.1:8080' % proto, ['%s://' % proto, '127.0.0.1', '8080'],
39 ('%s://127.0.0.1:8080' % proto, ['%s://' % proto, '127.0.0.1', '8080'],
40 '%s://127.0.0.1:8080' % proto),
40 '%s://127.0.0.1:8080' % proto),
41 ('%s://domain.org' % proto, ['%s://' % proto, 'domain.org'],
41 ('%s://domain.org' % proto, ['%s://' % proto, 'domain.org'],
42 '%s://domain.org' % proto),
42 '%s://domain.org' % proto),
43 ('%s://user:pass@domain.org:8080' % proto, ['%s://' % proto, 'domain.org',
43 ('%s://user:pass@domain.org:8080' % proto, ['%s://' % proto, 'domain.org',
44 '8080'],
44 '8080'],
45 '%s://domain.org:8080' % proto),
45 '%s://domain.org:8080' % proto),
46 ]
46 ]
47
47
48 proto = 'https'
48 proto = 'https'
49 TEST_URLS += [
49 TEST_URLS += [
50 ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
50 ('%s://127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
51 '%s://127.0.0.1' % proto),
51 '%s://127.0.0.1' % proto),
52 ('%s://marcink@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
52 ('%s://marcink@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
53 '%s://127.0.0.1' % proto),
53 '%s://127.0.0.1' % proto),
54 ('%s://marcink:pass@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
54 ('%s://marcink:pass@127.0.0.1' % proto, ['%s://' % proto, '127.0.0.1'],
55 '%s://127.0.0.1' % proto),
55 '%s://127.0.0.1' % proto),
56 ('%s://127.0.0.1:8080' % proto, ['%s://' % proto, '127.0.0.1', '8080'],
56 ('%s://127.0.0.1:8080' % proto, ['%s://' % proto, '127.0.0.1', '8080'],
57 '%s://127.0.0.1:8080' % proto),
57 '%s://127.0.0.1:8080' % proto),
58 ('%s://domain.org' % proto, ['%s://' % proto, 'domain.org'],
58 ('%s://domain.org' % proto, ['%s://' % proto, 'domain.org'],
59 '%s://domain.org' % proto),
59 '%s://domain.org' % proto),
60 ('%s://user:pass@domain.org:8080' % proto, ['%s://' % proto, 'domain.org',
60 ('%s://user:pass@domain.org:8080' % proto, ['%s://' % proto, 'domain.org',
61 '8080'],
61 '8080'],
62 '%s://domain.org:8080' % proto),
62 '%s://domain.org:8080' % proto),
63 ]
63 ]
64
64
65
65
66 class TestLibs(BaseTestCase):
66 class TestLibs(BaseTestCase):
67
67
68 @parameterized.expand(TEST_URLS)
68 @parameterized.expand(TEST_URLS)
69 def test_uri_filter(self, test_url, expected, expected_creds):
69 def test_uri_filter(self, test_url, expected, expected_creds):
70 from rhodecode.lib.utils2 import uri_filter
70 from rhodecode.lib.utils2 import uri_filter
71 self.assertEqual(uri_filter(test_url), expected)
71 self.assertEqual(uri_filter(test_url), expected)
72
72
73 @parameterized.expand(TEST_URLS)
73 @parameterized.expand(TEST_URLS)
74 def test_credentials_filter(self, test_url, expected, expected_creds):
74 def test_credentials_filter(self, test_url, expected, expected_creds):
75 from rhodecode.lib.utils2 import credentials_filter
75 from rhodecode.lib.utils2 import credentials_filter
76 self.assertEqual(credentials_filter(test_url), expected_creds)
76 self.assertEqual(credentials_filter(test_url), expected_creds)
77
77
78 @parameterized.expand([('t', True),
78 @parameterized.expand([('t', True),
79 ('true', True),
79 ('true', True),
80 ('y', True),
80 ('y', True),
81 ('yes', True),
81 ('yes', True),
82 ('on', True),
82 ('on', True),
83 ('1', True),
83 ('1', True),
84 ('Y', True),
84 ('Y', True),
85 ('yeS', True),
85 ('yeS', True),
86 ('Y', True),
86 ('Y', True),
87 ('TRUE', True),
87 ('TRUE', True),
88 ('T', True),
88 ('T', True),
89 ('False', False),
89 ('False', False),
90 ('F', False),
90 ('F', False),
91 ('FALSE', False),
91 ('FALSE', False),
92 ('0', False),
92 ('0', False),
93 ('-1', False),
93 ('-1', False),
94 ('', False)
94 ('', False)
95 ])
95 ])
96 def test_str2bool(self, str_bool, expected):
96 def test_str2bool(self, str_bool, expected):
97 from rhodecode.lib.utils2 import str2bool
97 from rhodecode.lib.utils2 import str2bool
98 self.assertEqual(str2bool(str_bool), expected)
98 self.assertEqual(str2bool(str_bool), expected)
99
99
100 def test_mention_extractor(self):
100 def test_mention_extractor(self):
101 from rhodecode.lib.utils2 import extract_mentioned_users
101 from rhodecode.lib.utils2 import extract_mentioned_users
102 sample = (
102 sample = (
103 "@first hi there @marcink here's my email marcin@email.com "
103 "@first hi there @marcink here's my email marcin@email.com "
104 "@lukaszb check @one_more22 it pls @ ttwelve @D[] @one@two@three "
104 "@lukaszb check @one_more22 it pls @ ttwelve @D[] @one@two@three "
105 "@MARCIN @maRCiN @2one_more22 @john please see this http://org.pl "
105 "@MARCIN @maRCiN @2one_more22 @john please see this http://org.pl "
106 "@marian.user just do it @marco-polo and next extract @marco_polo "
106 "@marian.user just do it @marco-polo and next extract @marco_polo "
107 "user.dot hej ! not-needed maril@domain.org"
107 "user.dot hej ! not-needed maril@domain.org"
108 )
108 )
109
109
110 s = sorted([
110 s = sorted([
111 'first', 'marcink', 'lukaszb', 'one_more22', 'MARCIN', 'maRCiN', 'john',
111 'first', 'marcink', 'lukaszb', 'one_more22', 'MARCIN', 'maRCiN', 'john',
112 'marian.user', 'marco-polo', 'marco_polo'
112 'marian.user', 'marco-polo', 'marco_polo'
113 ], key=lambda k: k.lower())
113 ], key=lambda k: k.lower())
114 self.assertEqual(s, extract_mentioned_users(sample))
114 self.assertEqual(s, extract_mentioned_users(sample))
115
115
116 @parameterized.expand([
116 @parameterized.expand([
117 (dict(), u'just now'),
117 (dict(), u'just now'),
118 (dict(seconds= -1), u'1 second ago'),
118 (dict(seconds= -1), u'1 second ago'),
119 (dict(seconds= -60 * 2), u'2 minutes ago'),
119 (dict(seconds= -60 * 2), u'2 minutes ago'),
120 (dict(hours= -1), u'1 hour ago'),
120 (dict(hours= -1), u'1 hour ago'),
121 (dict(hours= -24), u'1 day ago'),
121 (dict(hours= -24), u'1 day ago'),
122 (dict(hours= -24 * 5), u'5 days ago'),
122 (dict(hours= -24 * 5), u'5 days ago'),
123 (dict(months= -1), u'1 month ago'),
123 (dict(months= -1), u'1 month ago'),
124 (dict(months= -1, days= -2), u'1 month and 2 days ago'),
124 (dict(months= -1, days= -2), u'1 month and 2 days ago'),
125 (dict(years= -1, months= -1), u'1 year and 1 month ago'),
125 (dict(years= -1, months= -1), u'1 year and 1 month ago'),
126 ])
126 ])
127 def test_age(self, age_args, expected):
127 def test_age(self, age_args, expected):
128 from rhodecode.lib.utils2 import age
128 from rhodecode.lib.utils2 import age
129 from dateutil import relativedelta
129 from dateutil import relativedelta
130 n = datetime.datetime(year=2012, month=5, day=17)
130 n = datetime.datetime(year=2012, month=5, day=17)
131 delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
131 delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
132 self.assertEqual(age(n + delt(**age_args), now=n), expected)
132 self.assertEqual(age(n + delt(**age_args), now=n), expected)
133
133
134 @parameterized.expand([
134 @parameterized.expand([
135
135
136 (dict(), u'just now'),
136 (dict(), u'just now'),
137 (dict(seconds=1), u'in 1 second'),
137 (dict(seconds=1), u'in 1 second'),
138 (dict(seconds=60 * 2), u'in 2 minutes'),
138 (dict(seconds=60 * 2), u'in 2 minutes'),
139 (dict(hours=1), u'in 1 hour'),
139 (dict(hours=1), u'in 1 hour'),
140 (dict(hours=24), u'in 1 day'),
140 (dict(hours=24), u'in 1 day'),
141 (dict(hours=24 * 5), u'in 5 days'),
141 (dict(hours=24 * 5), u'in 5 days'),
142 (dict(months=1), u'in 1 month'),
142 (dict(months=1), u'in 1 month'),
143 (dict(months=1, days=1), u'in 1 month and 1 day'),
143 (dict(months=1, days=1), u'in 1 month and 1 day'),
144 (dict(years=1, months=1), u'in 1 year and 1 month')
144 (dict(years=1, months=1), u'in 1 year and 1 month')
145 ])
145 ])
146 def test_age_in_future(self, age_args, expected):
146 def test_age_in_future(self, age_args, expected):
147 from rhodecode.lib.utils2 import age
147 from rhodecode.lib.utils2 import age
148 from dateutil import relativedelta
148 from dateutil import relativedelta
149 n = datetime.datetime(year=2012, month=5, day=17)
149 n = datetime.datetime(year=2012, month=5, day=17)
150 delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
150 delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs)
151 self.assertEqual(age(n + delt(**age_args), now=n), expected)
151 self.assertEqual(age(n + delt(**age_args), now=n), expected)
152
152
153 def test_tag_exctrator(self):
153 def test_tag_exctrator(self):
154 sample = (
154 sample = (
155 "hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
155 "hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]"
156 "[requires] [stale] [see<>=>] [see => http://url.com]"
156 "[requires] [stale] [see<>=>] [see => http://url.com]"
157 "[requires => url] [lang => python] [just a tag]"
157 "[requires => url] [lang => python] [just a tag]"
158 "[,d] [ => ULR ] [obsolete] [desc]]"
158 "[,d] [ => ULR ] [obsolete] [desc]]"
159 )
159 )
160 from rhodecode.lib.helpers import desc_stylize
160 from rhodecode.lib.helpers import desc_stylize
161 res = desc_stylize(sample)
161 res = desc_stylize(sample)
162 self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
162 self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
163 self.assertTrue('<div class="metatag" tag="obsolete">obsolete</div>' in res)
163 self.assertTrue('<div class="metatag" tag="obsolete">obsolete</div>' in res)
164 self.assertTrue('<div class="metatag" tag="stale">stale</div>' in res)
164 self.assertTrue('<div class="metatag" tag="stale">stale</div>' in res)
165 self.assertTrue('<div class="metatag" tag="lang">python</div>' in res)
165 self.assertTrue('<div class="metatag" tag="lang">python</div>' in res)
166 self.assertTrue('<div class="metatag" tag="requires">requires =&gt; <a href="/url">url</a></div>' in res)
166 self.assertTrue('<div class="metatag" tag="requires">requires =&gt; <a href="/url">url</a></div>' in res)
167 self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
167 self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
168
168
169 def test_alternative_gravatar(self):
169 def test_alternative_gravatar(self):
170 from rhodecode.lib.helpers import gravatar_url
170 from rhodecode.lib.helpers import gravatar_url
171 _md5 = lambda s: hashlib.md5(s).hexdigest()
171 _md5 = lambda s: hashlib.md5(s).hexdigest()
172
172
173 def fake_conf(**kwargs):
173 def fake_conf(**kwargs):
174 from pylons import config
174 from pylons import config
175 config['app_conf'] = {}
175 config = {}
176 config['app_conf']['use_gravatar'] = True
176 config['use_gravatar'] = True
177 config['app_conf'].update(kwargs)
177 config.update(kwargs)
178 return config
178 return config
179
179
180 class fake_url():
180 class fake_url():
181 @classmethod
181 @classmethod
182 def current(cls, *args, **kwargs):
182 def current(cls, *args, **kwargs):
183 return 'https://server.com'
183 return 'https://server.com'
184
184
185 with mock.patch('pylons.url', fake_url):
185 with mock.patch('pylons.url', fake_url):
186 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
186 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
187 with mock.patch('pylons.config', fake):
187 with mock.patch('rhodecode.CONFIG', fake):
188 from pylons import url
188 from pylons import url
189 assert url.current() == 'https://server.com'
189 assert url.current() == 'https://server.com'
190 grav = gravatar_url(email_address='test@foo.com', size=24)
190 grav = gravatar_url(email_address='test@foo.com', size=24)
191 assert grav == 'http://test.com/test@foo.com'
191 assert grav == 'http://test.com/test@foo.com'
192
192
193 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
193 fake = fake_conf(alternative_gravatar_url='http://test.com/{email}')
194 with mock.patch('pylons.config', fake):
194 with mock.patch('rhodecode.CONFIG', fake):
195 grav = gravatar_url(email_address='test@foo.com', size=24)
195 grav = gravatar_url(email_address='test@foo.com', size=24)
196 assert grav == 'http://test.com/test@foo.com'
196 assert grav == 'http://test.com/test@foo.com'
197
197
198 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}')
198 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}')
199 with mock.patch('pylons.config', fake):
199 with mock.patch('rhodecode.CONFIG', fake):
200 em = 'test@foo.com'
200 em = 'test@foo.com'
201 grav = gravatar_url(email_address=em, size=24)
201 grav = gravatar_url(email_address=em, size=24)
202 assert grav == 'http://test.com/%s' % (_md5(em))
202 assert grav == 'http://test.com/%s' % (_md5(em))
203
203
204 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}/{size}')
204 fake = fake_conf(alternative_gravatar_url='http://test.com/{md5email}/{size}')
205 with mock.patch('pylons.config', fake):
205 with mock.patch('rhodecode.CONFIG', fake):
206 em = 'test@foo.com'
206 em = 'test@foo.com'
207 grav = gravatar_url(email_address=em, size=24)
207 grav = gravatar_url(email_address=em, size=24)
208 assert grav == 'http://test.com/%s/%s' % (_md5(em), 24)
208 assert grav == 'http://test.com/%s/%s' % (_md5(em), 24)
209
209
210 fake = fake_conf(alternative_gravatar_url='{scheme}://{netloc}/{md5email}/{size}')
210 fake = fake_conf(alternative_gravatar_url='{scheme}://{netloc}/{md5email}/{size}')
211 with mock.patch('pylons.config', fake):
211 with mock.patch('rhodecode.CONFIG', fake):
212 em = 'test@foo.com'
212 em = 'test@foo.com'
213 grav = gravatar_url(email_address=em, size=24)
213 grav = gravatar_url(email_address=em, size=24)
214 assert grav == 'https://server.com/%s/%s' % (_md5(em), 24)
214 assert grav == 'https://server.com/%s/%s' % (_md5(em), 24)
215
215
216 def _quick_url(self, text, tmpl="""<a class="revision-link" href="%s">%s</a>""", url_=None):
216 def _quick_url(self, text, tmpl="""<a class="revision-link" href="%s">%s</a>""", url_=None):
217 """
217 """
218 Changes `some text url[foo]` => `some text <a href="/">foo</a>
218 Changes `some text url[foo]` => `some text <a href="/">foo</a>
219
219
220 :param text:
220 :param text:
221 """
221 """
222 import re
222 import re
223 # quickly change expected url[] into a link
223 # quickly change expected url[] into a link
224 URL_PAT = re.compile(r'(?:url\[)(.+?)(?:\])')
224 URL_PAT = re.compile(r'(?:url\[)(.+?)(?:\])')
225
225
226 def url_func(match_obj):
226 def url_func(match_obj):
227 _url = match_obj.groups()[0]
227 _url = match_obj.groups()[0]
228 return tmpl % (url_ or '/some-url', _url)
228 return tmpl % (url_ or '/some-url', _url)
229 return URL_PAT.sub(url_func, text)
229 return URL_PAT.sub(url_func, text)
230
230
231 @parameterized.expand([
231 @parameterized.expand([
232 ("",
232 ("",
233 ""),
233 ""),
234 ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68",
234 ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68",
235 "git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68"),
235 "git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68"),
236 ("from rev 000000000000",
236 ("from rev 000000000000",
237 "from rev url[000000000000]"),
237 "from rev url[000000000000]"),
238 ("from rev 000000000000123123 also rev 000000000000",
238 ("from rev 000000000000123123 also rev 000000000000",
239 "from rev url[000000000000123123] also rev url[000000000000]"),
239 "from rev url[000000000000123123] also rev url[000000000000]"),
240 ("this should-000 00",
240 ("this should-000 00",
241 "this should-000 00"),
241 "this should-000 00"),
242 ("longtextffffffffff rev 123123123123",
242 ("longtextffffffffff rev 123123123123",
243 "longtextffffffffff rev url[123123123123]"),
243 "longtextffffffffff rev url[123123123123]"),
244 ("rev ffffffffffffffffffffffffffffffffffffffffffffffffff",
244 ("rev ffffffffffffffffffffffffffffffffffffffffffffffffff",
245 "rev ffffffffffffffffffffffffffffffffffffffffffffffffff"),
245 "rev ffffffffffffffffffffffffffffffffffffffffffffffffff"),
246 ("ffffffffffff some text traalaa",
246 ("ffffffffffff some text traalaa",
247 "url[ffffffffffff] some text traalaa"),
247 "url[ffffffffffff] some text traalaa"),
248 ("""Multi line
248 ("""Multi line
249 123123123123
249 123123123123
250 some text 123123123123
250 some text 123123123123
251 sometimes !
251 sometimes !
252 """,
252 """,
253 """Multi line
253 """Multi line
254 url[123123123123]
254 url[123123123123]
255 some text url[123123123123]
255 some text url[123123123123]
256 sometimes !
256 sometimes !
257 """)
257 """)
258 ])
258 ])
259 def test_urlify_changesets(self, sample, expected):
259 def test_urlify_changesets(self, sample, expected):
260 def fake_url(self, *args, **kwargs):
260 def fake_url(self, *args, **kwargs):
261 return '/some-url'
261 return '/some-url'
262
262
263 expected = self._quick_url(expected)
263 expected = self._quick_url(expected)
264
264
265 with mock.patch('pylons.url', fake_url):
265 with mock.patch('pylons.url', fake_url):
266 from rhodecode.lib.helpers import urlify_changesets
266 from rhodecode.lib.helpers import urlify_changesets
267 self.assertEqual(urlify_changesets(sample, 'repo_name'), expected)
267 self.assertEqual(urlify_changesets(sample, 'repo_name'), expected)
268
268
269 @parameterized.expand([
269 @parameterized.expand([
270 ("",
270 ("",
271 "",
271 "",
272 ""),
272 ""),
273 ("https://svn.apache.org/repos",
273 ("https://svn.apache.org/repos",
274 "url[https://svn.apache.org/repos]",
274 "url[https://svn.apache.org/repos]",
275 "https://svn.apache.org/repos"),
275 "https://svn.apache.org/repos"),
276 ("http://svn.apache.org/repos",
276 ("http://svn.apache.org/repos",
277 "url[http://svn.apache.org/repos]",
277 "url[http://svn.apache.org/repos]",
278 "http://svn.apache.org/repos"),
278 "http://svn.apache.org/repos"),
279 ("from rev a also rev http://google.com",
279 ("from rev a also rev http://google.com",
280 "from rev a also rev url[http://google.com]",
280 "from rev a also rev url[http://google.com]",
281 "http://google.com"),
281 "http://google.com"),
282 ("""Multi line
282 ("""Multi line
283 https://foo.bar.com
283 https://foo.bar.com
284 some text lalala""",
284 some text lalala""",
285 """Multi line
285 """Multi line
286 url[https://foo.bar.com]
286 url[https://foo.bar.com]
287 some text lalala""",
287 some text lalala""",
288 "https://foo.bar.com")
288 "https://foo.bar.com")
289 ])
289 ])
290 def test_urlify_test(self, sample, expected, url_):
290 def test_urlify_test(self, sample, expected, url_):
291 from rhodecode.lib.helpers import urlify_text
291 from rhodecode.lib.helpers import urlify_text
292 expected = self._quick_url(expected,
292 expected = self._quick_url(expected,
293 tmpl="""<a href="%s">%s</a>""", url_=url_)
293 tmpl="""<a href="%s">%s</a>""", url_=url_)
294 self.assertEqual(urlify_text(sample), expected)
294 self.assertEqual(urlify_text(sample), expected)
General Comments 0
You need to be logged in to leave comments. Login now