summaryrefslogtreecommitdiffstats
path: root/askbot/tests/utils_tests.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-27 15:09:37 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-27 15:09:37 -0400
commit1e47fb23634dbdf406a3e8893120793b7e065da5 (patch)
tree24a8ae6aa62fa51b374c63c3cf8b4b842a78d1ec /askbot/tests/utils_tests.py
parent56f56f2077d4e4f5fc149eb222e33801ad036033 (diff)
downloadaskbot-1e47fb23634dbdf406a3e8893120793b7e065da5.tar.gz
askbot-1e47fb23634dbdf406a3e8893120793b7e065da5.tar.bz2
askbot-1e47fb23634dbdf406a3e8893120793b7e065da5.zip
refactored the absolutize_urls function and the with_settings decorator for the test cases
Diffstat (limited to 'askbot/tests/utils_tests.py')
-rw-r--r--askbot/tests/utils_tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/askbot/tests/utils_tests.py b/askbot/tests/utils_tests.py
index 7f252b69..bc3bb0bb 100644
--- a/askbot/tests/utils_tests.py
+++ b/askbot/tests/utils_tests.py
@@ -1,5 +1,8 @@
from django.test import TestCase
+from askbot.tests.utils import with_settings
from askbot.utils.url_utils import urls_equal
+from askbot.utils.html import absolutize_urls
+from askbot.conf import settings as askbot_settings
class UrlUtilsTests(TestCase):
@@ -15,3 +18,24 @@ class UrlUtilsTests(TestCase):
self.assertTrue(e('http://cnn.com/path', 'http://cnn.com/path/', True))
self.assertFalse(e('http://cnn.com/path', 'http://cnn.com/path/'))
+
+class HTMLUtilsTests(TestCase):
+ """tests for :mod:`askbot.utils.html` module"""
+
+ @with_settings(APP_URL='http://example.com')
+ def test_absolutize_image_urls(self):
+ text = """<img class="junk" src="/some.gif"> <img class="junk" src="/cat.gif"> <IMG SRC='/some.png'>"""
+ #jinja register.filter decorator works in a weird way
+ self.assertEqual(
+ absolutize_urls(text),
+ '<img class="junk" src="http://example.com/some.gif" style="max-width:500px;"> <img class="junk" src="http://example.com/cat.gif" style="max-width:500px;"> <IMG SRC="http://example.com/some.png" style="max-width:500px;">'
+ )
+
+ @with_settings(APP_URL='http://example.com')
+ def test_absolutize_anchor_urls(self):
+ text = """<a class="junk" href="/something">link</a> <A HREF='/something'>link</A>"""
+ #jinja register.filter decorator works in a weird way
+ self.assertEqual(
+ absolutize_urls(text),
+ '<a class="junk" href="http://example.com/something">link</a> <A HREF="http://example.com/something">link</A>'
+ )