Commit 8f109731 authored by Hugo H. Maia Vieira's avatar Hugo H. Maia Vieira

Refactoring

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41104 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a61fd142
...@@ -83,10 +83,10 @@ class OOGranulate(object): ...@@ -83,10 +83,10 @@ class OOGranulate(object):
def getImageItemList(self): def getImageItemList(self):
"""Return a list of tuples with the id and title of image files""" """Return a list of tuples with the id and title of image files"""
xml_images = self._getElementsByTagName(self.document.parsed_content, xml_image_list = self._getElementsByTagName(self.document.parsed_content,
'draw:image') 'draw:image')
image_list = [] image_list = []
for image in xml_images: for image in xml_image_list:
title = self._getImageTitle(image) title = self._getImageTitle(image)
id = image.values()[0].split('/')[-1] id = image.values()[0].split('/')[-1]
image_list.append((id, title)) image_list.append((id, title))
......
...@@ -39,27 +39,27 @@ class TestOOGranulate(cloudoooTestCase): ...@@ -39,27 +39,27 @@ class TestOOGranulate(cloudoooTestCase):
def testGetElementsByTagName(self): def testGetElementsByTagName(self):
"""Test if _getElementsByTagName() returns right elements list""" """Test if _getElementsByTagName() returns right elements list"""
elements = self.oogranulate._getElementsByTagName( element_list = self.oogranulate._getElementsByTagName(
self.oogranulate.document.parsed_content, self.oogranulate.document.parsed_content,
'draw:image') 'draw:image')
self.assertEquals(len(elements), 5) self.assertEquals(len(element_list), 5)
for element in elements: for element in element_list:
self.assertTrue(element.tag.endswith('image')) self.assertTrue(element.tag.endswith('image'))
def testHasAncertor(self): def testHasAncertor(self):
images = self.oogranulate._getElementsByTagName( image_list = self.oogranulate._getElementsByTagName(
self.oogranulate.document.parsed_content, self.oogranulate.document.parsed_content,
'draw:image') 'draw:image')
self.assertFalse(self.oogranulate._hasAncestor(images[0], 'text-box')) self.assertFalse(self.oogranulate._hasAncestor(image_list[0], 'text-box'))
self.assertTrue(self.oogranulate._hasAncestor(images[0], 'frame')) self.assertTrue(self.oogranulate._hasAncestor(image_list[0], 'frame'))
self.assertTrue(self.oogranulate._hasAncestor(images[2], 'text-box')) self.assertTrue(self.oogranulate._hasAncestor(image_list[2], 'text-box'))
def testGetImageTitle(self): def testGetImageTitle(self):
images = self.oogranulate._getElementsByTagName( image_list = self.oogranulate._getElementsByTagName(
self.oogranulate.document.parsed_content, self.oogranulate.document.parsed_content,
'draw:image') 'draw:image')
self.assertEquals(self.oogranulate._getImageTitle(images[0]), '') self.assertEquals(self.oogranulate._getImageTitle(image_list[0]), '')
self.assertEquals(self.oogranulate._getImageTitle(images[2]), self.assertEquals(self.oogranulate._getImageTitle(image_list[2]),
'Illustration 1: TioLive Logo') 'Illustration 1: TioLive Logo')
def testgetTableItemList(self): def testgetTableItemList(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment