示例#1
0
class TestOdfDocument(HandlerTestCase):

  def setUp(self):
    data = open('./data/granulate_test.odt').read()
    self.oodocument = OdfDocument(data, 'odt')

  def testReceivedGoodFile(self):
    """Test if received path is from a good document returing an ZipFile"""
    self.assertTrue(isinstance(self.oodocument._zipfile, ZipFile))

  def testGetContentXml(self):
    """Test if the getContentXml method returns the content.xml file"""
    content_xml = self.oodocument.getContentXml()
    self.assertTrue('The content of this file is just' in content_xml)

  def testGetExistentFile(self):
    """Test if the getFile method returns the requested file"""
    requested_file = self.oodocument.getFile('content.xml')
    self.assertEquals(requested_file, self.oodocument.getContentXml())

  def testGetNotPresentFile(self):
    """Test if the getFile method returns None for not present file request"""
    requested_file = self.oodocument.getFile('not_present.xml')
    self.assertEquals(requested_file, '')

  def testParseContent(self):
    """Test if the _parsed_content attribute is the parsed content.xml"""
    # XXX not sure it is good to store parsed document everytime
    self.assertTrue(isinstance(self.oodocument.parsed_content, etree._Element))
    self.assertTrue(self.oodocument.parsed_content.tag.endswith(
                    'document-content'))
示例#2
0
class TestOdfDocument(HandlerTestCase):
    def setUp(self):
        data = open('./data/granulate_test.odt').read()
        self.oodocument = OdfDocument(data, 'odt')

    def testReceivedGoodFile(self):
        """Test if received path is from a good document returing an ZipFile"""
        self.assertTrue(isinstance(self.oodocument._zipfile, ZipFile))

    def testGetContentXml(self):
        """Test if the getContentXml method returns the content.xml file"""
        content_xml = self.oodocument.getContentXml()
        self.assertTrue('The content of this file is just' in content_xml)

    def testGetExistentFile(self):
        """Test if the getFile method returns the requested file"""
        requested_file = self.oodocument.getFile('content.xml')
        self.assertEquals(requested_file, self.oodocument.getContentXml())

    def testGetNotPresentFile(self):
        """Test if the getFile method returns None for not present file request"""
        requested_file = self.oodocument.getFile('not_present.xml')
        self.assertEquals(requested_file, '')

    def testParseContent(self):
        """Test if the _parsed_content attribute is the parsed content.xml"""
        # XXX not sure it is good to store parsed document everytime
        self.assertTrue(
            isinstance(self.oodocument.parsed_content, etree._Element))
        self.assertTrue(
            self.oodocument.parsed_content.tag.endswith('document-content'))
示例#3
0
 def setUp(self):
   data = open('./data/granulate_test.odt').read()
   self.oodocument = OdfDocument(data, 'odt')
示例#4
0
 def __init__(self, file, source_format):
   self.document = OdfDocument(file, source_format)
示例#5
0
 def setUp(self):
     data = open('./data/granulate_test.odt').read()
     self.oodocument = OdfDocument(data, 'odt')