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/19 13:38:12 UTC

[47/50] [abbrv] 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/4e37a231
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/4e37a231
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/4e37a231

Branch: refs/heads/ib/7924
Commit: 4e37a23122c481343043bae364f3b5e3d7ddb9a7
Parents: 939847b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Oct 15 18:40:51 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Thu Oct 15 18:40:51 2015 +0300

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


http://git-wip-us.apache.org/repos/asf/allura/blob/4e37a231/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index bb5d80e..8b7c0c5 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -881,3 +881,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': '>'}))