From edf87682ddc19c63a9a527ccb3d16bdf0a5593b3 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Thu, 11 Oct 2012 17:20:07 +0300
Subject: [PATCH] Test that embedded in Web Page's content relative images get
 auto converted.

---
 .../ERP5OOo/tests/testDmsWithPreConversion.py | 27 ++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/product/ERP5OOo/tests/testDmsWithPreConversion.py b/product/ERP5OOo/tests/testDmsWithPreConversion.py
index 9a9ba5ea07..10e9c14c19 100644
--- a/product/ERP5OOo/tests/testDmsWithPreConversion.py
+++ b/product/ERP5OOo/tests/testDmsWithPreConversion.py
@@ -28,7 +28,7 @@
 ##############################################################################
 
 import unittest
-from testDms import TestDocument
+from testDms import TestDocument, makeFileUpload
 
 class TestDocumentWithPreConversion(TestDocument):
   """
@@ -40,6 +40,31 @@ class TestDocumentWithPreConversion(TestDocument):
   def getTitle(self):
     return "DMS with Preconversion"
 
+  def test_preConvertedEmbeddedImageInWebPageContent(self):
+    # create an image
+    upload_file = makeFileUpload('cmyk_sample.jpg')
+    image = self.portal.image_module.newContent(portal_type='Image',
+                                               reference='Embedded-XXX',
+                                               version='001',
+                                               language='en')
+    image.edit(file=upload_file)
+    image.publish()
+    self.tic()
+
+    web_page = self.portal.web_page_module.newContent(portal_type="Web Page")
+    web_page.setTextContent('''<b> test </b>
+<img src="Embedded-XXX?format=png&display=large&quality=75"/>
+<img src="Embedded-XXX?format=jpeg&display=large&quality=75"/>''')
+    self.tic()
+
+    # check that referenced in Web Page's content image(s) is well converted
+    self.assertTrue(image.hasConversion(**{'format':'jpeg', 'display':'large', 'quality':75}))
+    self.assertTrue(image.hasConversion(**{'format':'png', 'display':'large', 'quality':75}))
+    self.assertSameSet(['Embedded-XXX?format=png&display=large&quality=75', \
+                        'Embedded-XXX?format=jpeg&display=large&quality=75'], 
+                        web_page.Base_extractImageUrlList())
+
+
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestDocumentWithPreConversion))
-- 
2.30.9