You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/10/27 18:07:34 UTC

[17/40] allura git commit: [#7924] ticket:837 Add tests for Icon.render

[#7924] ticket:837 Add tests for Icon.render


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/35098db0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/35098db0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/35098db0

Branch: refs/heads/ib/7924
Commit: 35098db06f1589d7326c478624bf5308fa353e65
Parents: fb51d9b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Oct 15 18:40:51 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Oct 27 16:22:10 2015 +0200

----------------------------------------------------------------------
 Allura/allura/tests/test_globals.py | 37 ++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/35098db0/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 139250e..8dbeca7 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -869,3 +869,40 @@ class TestNeighborhoodCache(object):
         cache = NeighborhoodCache(30)
         assert_equal(cache._expired({'ts': _now - dt.timedelta(seconds=29)}), False)
         assert_equal(cache._expired({'ts': _now - dt.timedelta(seconds=30)}), True)
+
+
+class TestIconRender(object):
+
+    def setUp(self):
+        self.i = g.icons['edit']
+
+    def test_default(self):
+        html = u'<a class="icon fa fa-edit" href="#" title="Edit"></a>'
+        assert_equal(html, self.i.render())
+
+    def test_show_title(self):
+        html = u'<a class="icon fa fa-edit" href="#" title="Edit"><span>&nbsp;Edit</span></a>'
+        assert_equal(html, self.i.render(show_title=True))
+
+        html = u'<a class="icon fa fa-edit" href="#" title="&lt;script&gt;"><span>&nbsp;&lt;script&gt;</span></a>'
+        assert_equal(html, self.i.render(show_title=True, title="<script>"))
+
+    def test_extra_css(self):
+        html = u'<a class="icon fa fa-edit reply btn" href="#" title="Edit"></a>'
+        assert_equal(html, self.i.render(extra_css='reply btn'))
+
+    def test_no_closing_tag(self):
+        html = u'<a class="icon fa fa-edit" href="#" title="Edit">'
+        assert_equal(html, self.i.render(closing_tag=False))
+
+    def test_tag(self):
+        html = u'<div class="icon fa fa-edit" href="#" title="Edit"></div>'
+        assert_equal(html, self.i.render(tag='div'))
+
+    def test_kwargs(self):
+        html = u'<a class="icon fa fa-edit" data-id="123" href="#" title="Edit"></a>'
+        assert_equal(html, self.i.render(**{'data-id': '123'}))
+
+    def test_escaping(self):
+        html = u'<a class="icon fa fa-edit &#34;" data-url="&gt;" href="#" title="Edit"></a>'
+        assert_equal(html, self.i.render(extra_css='"', **{'data-url': '>'}))