changeset 3268:753f234085c2

macro.EmbedObject: fixed double escaping for urls and added a unit test for urls
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 16 Mar 2008 19:24:02 +0100
parents 65be8803b8df
children 99e7f184541f
files MoinMoin/macro/EmbedObject.py MoinMoin/macro/_tests/test_EmbedObject.py
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/EmbedObject.py	Sun Mar 16 17:50:51 2008 +0100
+++ b/MoinMoin/macro/EmbedObject.py	Sun Mar 16 19:24:02 2008 +0100
@@ -99,7 +99,7 @@
         else:
             mt = wikiutil.MimeType() # initialize dict
             mt.major, mt.minor = url_mimetype.split('/')
-            url = wikiutil.escape(target)
+            url = target
 
         # XXX Should better use formatter.embed if available?
         if not mt:
--- a/MoinMoin/macro/_tests/test_EmbedObject.py	Sun Mar 16 17:50:51 2008 +0100
+++ b/MoinMoin/macro/_tests/test_EmbedObject.py	Sun Mar 16 19:24:02 2008 +0100
@@ -39,7 +39,7 @@
                 os.remove(fpath)
 
     def _make_macro(self):
-        """Test helper"""
+        """ Test helper """
         from MoinMoin.parser.text import Parser
         from MoinMoin.formatter.text_html import Formatter
         p = Parser("##\n", self.request)
@@ -57,7 +57,7 @@
         self.page.saveText(body, 0)
 
     def testEmbedObjectDefaultValues(self):
-        """ tests default values of macro EmbedObject"""
+        """ tests default values of macro EmbedObject """
         text = '= Example ='
         self._createTestPage(text)
         m = self._make_macro()
@@ -68,7 +68,7 @@
         assert 'value="transparent"' in result
 
     def testEmbedObjectPercentHeight(self):
-        """ tests default values of macro EmbedObject"""
+        """ tests a unit value for macro EmbedObject """
         text = '= Example2 ='
         self._createTestPage(text)
         m = self._make_macro()
@@ -79,5 +79,14 @@
         assert 'height="50%"' in result
         assert 'align="middle"' in result
 
+    def testEmbedObjectFromUrl(self):
+        """ tests using a URL for macro EmbedObject """
+        text = '= Example3 ='
+        self._createTestPage(text)
+        m = self._make_macro()
+        target = 'http://localhost/%s?action=AttachFile&do=view&target=test.ogg' % self.pagename
+        result = m.execute('EmbedObject', u'target=%s, url_mimetype=application/ogg' % target)
+        assert '<object data="http://localhost/AutoCreatedMoinMoinTemporaryTestPageForEmbedObject?action=AttachFile&amp;do=view&amp;target=test.ogg" type="application/ogg"' in result
+
 coverage_modules = ['MoinMoin.macro.EmbedObject']