changeset 2815:104590a28e54

test_ImageLink: added two new tests, fixed class name
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 09 Sep 2007 23:30:58 +0200
parents 7bde33d15531
children 50fcf4ba8374
files MoinMoin/macro/_tests/test_ImageLink.py
diffstat 1 files changed, 26 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/_tests/test_ImageLink.py	Sun Sep 09 22:19:45 2007 +0200
+++ b/MoinMoin/macro/_tests/test_ImageLink.py	Sun Sep 09 23:30:58 2007 +0200
@@ -8,13 +8,14 @@
 """
 import os
 from MoinMoin import macro, wikiutil
+from MoinMoin.action.AttachFile import add_attachment
 from MoinMoin.logfile import eventlog
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.parser.text_moin_wiki import Parser
 
-class TestHits:
-    """Hits: testing Hits macro """
+class TestImageLink:
+    """ImageLink: testing ImageLink macro """
 
     def setup_class(self):
         self.pagename = u'AutoCreatedMoinMoinTemporaryTestPageForImageLink'
@@ -74,12 +75,34 @@
         """ macro ImageLink test: <<ImageLink(http://static.wikiwikiweb.de/logos/moindude.png, alt=The old dude, FrontPage)>>
         order of keywords to parameter list is independent
         """
-        self.shouldDeleteTestPage = True
+        self.shouldDeleteTestPage = False
 
         result = self._test_macro('ImageLink', 'http://static.wikiwikiweb.de/logos/moindude.png, alt=The old dude, FrontPage')
         expected = '<a href="./FrontPage"><img alt="The old dude" src="http://static.wikiwikiweb.de/logos/moindude.png" title="The old dude" /></a>'
         assert result == expected
 
+    def testImageLinkToImage(self):
+        """ macro ImageLink test: <<ImageLink(http://static.wikiwikiweb.de/logos/moindude.png, alt=The old dude, width=200)>>
+            has to link to the image
+        """
+        self.shouldDeleteTestPage = False
+
+        result = self._test_macro('ImageLink', 'http://static.wikiwikiweb.de/logos/moindude.png, alt=The old dude, width=200')
+        expected = '<a href="http://static.wikiwikiweb.de/logos/moindude.png"><img alt="The old dude" src="http://static.wikiwikiweb.de/logos/moindude.png" title="The old dude" width="200" /></a>'
+        assert result == expected
+
+    def testImageLinktoAttachment(self):
+        """ macro ImageLink test: <<ImageLink(moindude.png, attachment:moindude.png, width=200)>>
+            has to link to the attachment:moindude.png
+        """
+        self.shouldDeleteTestPage = True
+        # If we do test for real content we have to upload a real image here
+        add_attachment(self.request, self.pagename, 'moindude.png', "Test content", True)
+
+        result = self._test_macro('ImageLink', 'moindude.png, attachment:moindude.png, width=200')
+        expected = '<a href="./AutoCreatedMoinMoinTemporaryTestPageForImageLink?action=AttachFile&amp;do=get&amp;target=moindude.png"><img alt="./AutoCreatedMoinMoinTemporaryTestPageForImageLink?action=AttachFile&amp;do=get&amp;target=moindude.png" src="./AutoCreatedMoinMoinTemporaryTestPageForImageLink?action=AttachFile&amp;do=get&amp;target=moindude.png" title="./AutoCreatedMoinMoinTemporaryTestPageForImageLink?action=AttachFile&amp;do=get&amp;target=moindude.png" width="200" /></a>'
+
+        assert result == expected
 
 coverage_modules = ['MoinMoin.macro.ImageLink']