def testSendZipFile(self):
   """Tests if the htm is extrated from zipfile"""
   zip_input_url = 'data/test.zip'
   data = open(zip_input_url).read()
   zipdocument = FileSystemDocument(self.tmp_url, data, 'zip')
   mime = magic.Magic(mime=True)
   mimetype = mime.from_buffer(zipdocument.getContent(True))
   self.assertEquals(mimetype, "application/zip")
   mimetype = mime.from_buffer(zipdocument.getContent())
   self.assertEquals(mimetype, "text/html")
   zipfile = ZipFile(StringIO(zipdocument.getContent(True)))
   self.assertEquals(sorted(zipfile.namelist()),
               sorted(['logo.gif', 'test.htm']))
Esempio n. 2
0
 def __init__(self, base_folder_url, data, source_format, **kw):
     """Creates document in file system and loads it in OOo."""
     self.document = FileSystemDocument(base_folder_url, data,
                                        source_format)
     self.zip = kw.get('zip', False)
     self.uno_path = kw.get("uno_path", None)
     self.office_binary_path = kw.get("office_binary_path", None)
     self.timeout = kw.get("timeout", 600)
     self.refresh = kw.get('refresh', False)
     self.source_format = source_format
     if not self.uno_path:
         self.uno_path = environ.get("uno_path")
     if not self.office_binary_path:
         self.office_binary_path = environ.get("office_binary_path")
 def afterSetUp(self):
   """ """
   openoffice.acquire()
   self.hostname, self.port = openoffice.getAddress()
   data = open("data/test.odt", 'r').read()
   self.document = FileSystemDocument(self.tmp_url, data, 'odt')
 def setUp(self):
   """Create data to tests and instantiated a FileSystemDocument"""
   self.tmp_url = '/tmp'
   self.data = decodestring("cloudooo Test")
   self.fsdocument = FileSystemDocument(self.tmp_url, self.data, 'txt')