changeset 2095:11ba582e3063

Fixes #360, svg now handled by <img> instead of <object>, added tests
author sharky93 <rishabhr123@gmail.com>
date Sat, 20 Apr 2013 19:51:48 +0530
parents 7c00da767896
children c99479988451
files MoinMoin/converter/_tests/test_image.py MoinMoin/converter/html_out.py
diffstat 2 files changed, 41 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/converter/_tests/test_image.py	Sat Apr 20 19:51:48 2013 +0530
@@ -0,0 +1,40 @@
+# Copyright: 2013 MoinMoin:RishabhRaj
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+MoinMoin - Tests for MoinMoin.converter for different imagetypes
+"""
+
+import pytest
+
+from emeraldtree import tree as ET
+
+from MoinMoin.converter.html_out import ConverterPage
+
+
+class TestImg(object):
+    def setup_class(self):
+        self.converter = ConverterPage()
+
+    def testImage(self):
+        tree_xml = ('<ns0:page ns0:page-href="wiki:///Home" xmlns:ns0="http://moinmo.in/namespaces/page" '
+                    'xmlns:ns1="http://www.w3.org/2001/XInclude" xmlns:ns2="http://www.w3.org/1999/xhtml" '
+                    'xmlns:ns3="http://www.w3.org/1999/xlink"><ns0:body><ns0:p ns2:data-lineno="1">'
+                    '<ns0:page ns2:class="moin-transclusion" ns0:page-href="wiki:///imagetest" ns2:data-href="/imagetest">'
+                    '<ns0:body><ns0:object ns3:href="/+get/+2882c905b2ab409fbf79cd05637a112d/imagetest" ns0:type="{0}" />'
+                    '</ns0:body></ns0:page></ns0:p></ns0:body></ns0:page>')
+        tests = [
+            ('image/jpeg', 'img'),
+            ('image/svg+xml', 'img'),
+            ('image/png', 'img'),
+            ('image/gif', 'img'),
+        ]
+
+        for imagetype, tag_expected in tests:
+            self.runTest(tree_xml.format(imagetype), tag_expected)
+
+    def runTest(self, tree_xml, tag_expected):
+        tree = ET.XML(tree_xml)
+        tree = self.converter(tree)
+        assert len(tree) and len(tree[0]) and len(tree[0][0]) == 1
+        assert tree[0][0][0].tag.name == tag_expected
--- a/MoinMoin/converter/html_out.py	Thu Apr 11 21:21:30 2013 +0200
+++ b/MoinMoin/converter/html_out.py	Sat Apr 20 19:51:48 2013 +0530
@@ -338,9 +338,7 @@
         Return value is an str, one of the following:
             image, video, audio, object
         """
-        if Type('image/').issupertype(mimetype) and not Type('image/svg+xml').issupertype(mimetype):
-            # Firefox fails completely to show svg in img tags (displays: nothing).
-            # Firefox displays them with on object tag (but sometimes displays scrollbars without need).
+        if Type('image/').issupertype(mimetype):
             return "img"
         elif Type('video/').issupertype(mimetype):
             return "video"