[Erp5-report] r41116 hugo.maia - in /erp5/trunk/utils/cloudooo/cloudooo: ./ granulate/ inte...
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Dec 4 00:26:38 CET 2010
Author: hugo.maia
Date: Sat Dec 4 00:26:38 2010
New Revision: 41116
URL: http://svn.erp5.org?rev=41116&view=rev
Log:
Add getImage for OOGranulate
Modified:
erp5/trunk/utils/cloudooo/cloudooo/CHANGES.txt
erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py
erp5/trunk/utils/cloudooo/cloudooo/interfaces/granulate.py
erp5/trunk/utils/cloudooo/cloudooo/tests/testOOGranulate.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/CHANGES.txt?rev=41116&r1=41115&r2=41116&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/CHANGES.txt [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/CHANGES.txt [utf8] Sat Dec 4 00:26:38 2010
@@ -1,5 +1,6 @@
1.0.10 (unreleased)
===================
+ - Add getImage for OOGranulate
- Add getImageItemList for OOGranulate
- Add OdfDocument
- Add granulate interface.
Modified: erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py?rev=41116&r1=41115&r2=41116&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py [utf8] Sat Dec 4 00:26:38 2010
@@ -92,9 +92,10 @@ class OOGranulate(object):
image_list.append((id, title))
return image_list
- def getImage(self, file, image_id, format=None, resolution=None, **kw):
+ def getImage(self, id, format=None, resolution=None, **kw):
"""Return the given image."""
- raise NotImplementedError
+ path = 'Pictures/%s' % id
+ return self.document.getFile(path)
def getParagraphItemList(self, file):
"""Returns the list of paragraphs in the form of (id, class) where class
Modified: erp5/trunk/utils/cloudooo/cloudooo/interfaces/granulate.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/interfaces/granulate.py?rev=41116&r1=41115&r2=41116&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/interfaces/granulate.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/interfaces/granulate.py [utf8] Sat Dec 4 00:26:38 2010
@@ -48,7 +48,7 @@ class IImageGranulator(Interface):
def getImageItemList():
"""Return the list of images in the form of (id, title)."""
- def getImage(image_id, format=None, resolution=None, **kw):
+ def getImage(id, format=None, resolution=None, **kw):
"""Return the given image."""
Modified: erp5/trunk/utils/cloudooo/cloudooo/tests/testOOGranulate.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/tests/testOOGranulate.py?rev=41116&r1=41115&r2=41116&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/tests/testOOGranulate.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/tests/testOOGranulate.py [utf8] Sat Dec 4 00:26:38 2010
@@ -27,6 +27,8 @@
##############################################################################
import unittest
+from zipfile import ZipFile
+from StringIO import StringIO
from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.granulate.oogranulate import OOGranulate
@@ -47,6 +49,7 @@ class TestOOGranulate(cloudoooTestCase):
self.assertTrue(element.tag.endswith('image'))
def testHasAncertor(self):
+ """_hasAncestor() should vefify if the elements has the ancestor or not"""
image_list = self.oogranulate._getElementsByTagName(
self.oogranulate.document.parsed_content,
'draw:image')
@@ -55,6 +58,7 @@ class TestOOGranulate(cloudoooTestCase):
self.assertTrue(self.oogranulate._hasAncestor(image_list[2], 'text-box'))
def testGetImageTitle(self):
+ """_hasAncestor() should vefify if the elements has the ancestor or not"""
image_list = self.oogranulate._getElementsByTagName(
self.oogranulate.document.parsed_content,
'draw:image')
@@ -92,13 +96,19 @@ class TestOOGranulate(cloudoooTestCase):
'Illustration 2: Again TioLive Logo'),
], image_list)
- def testGetImage(self):
- """Test if getImage() returns the right image file"""
- self.assertRaises(NotImplementedError, self.oogranulate.getImage,
- 'file',
- 'image_id',
- 'format',
- 'resolution')
+ def testGetImageSuccessfully(self):
+ """Test if getImage() returns the right image file successfully"""
+ data = open('./data/granulate_test.odt').read()
+ zip = ZipFile(StringIO(data))
+ image_id = '10000000000000C80000009C38276C51.jpg'
+ original_image = zip.read('Pictures/%s' % image_id)
+ geted_image = self.oogranulate.getImage(image_id)
+ self.assertEquals(original_image, geted_image)
+
+ def testGetImageWithoutSuccess(self):
+ """Test if getImage() returns an empty string for not existent id"""
+ geted_image = self.oogranulate.getImage('anything.png')
+ self.assertEquals('', geted_image)
def testGetParagraphItemList(self):
"""Test if getParagraphItemList() returns the right paragraphs list"""
More information about the Erp5-report
mailing list