def testConvertDocToOdt(self): """Test convert DOC to ODT""" data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), 'doc') doc_exported = handler.convert("odt") self._assert_document_output( doc_exported, "application/vnd.oasis.opendocument.text")
def testConvertWithOpenOfficeStopped(self): """Test convert with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), "doc") doc_exported = handler.convert("odt") self._assert_document_output(doc_exported, "application/vnd.oasis.opendocument.text")
def testRefreshOdt(self): """Test refresh argument""" # Check when refreshing is disabled data = encodestring(open("data/test_fields.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt', refresh=False) doc_exported = handler.convert("odt") document_output_url = path.join(self.tmp_url, "testExport.odt") self._save_document(document_output_url, doc_exported) zip_handler = ZipFile(document_output_url) content_tree = etree.fromstring(zip_handler.read('content.xml')) self.assertFalse(content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]', namespaces=content_tree.nsmap)) # Check when refreshing is enabled data = encodestring(open("data/test_fields.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt', refresh=True) doc_exported = handler.convert("odt") document_output_url = path.join(self.tmp_url, "testExport.odt") self._save_document(document_output_url, doc_exported) zip_handler = ZipFile(document_output_url) content_tree = etree.fromstring(zip_handler.read('content.xml')) self.assertTrue(content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]', namespaces=content_tree.nsmap))
def testConvertOdtToDoc(self): """Test convert ODT to DOC""" data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt') doc_exported = handler.convert("doc") self._assert_document_output(doc_exported, "application/msword")
def testGetMetadataWithOpenOfficeStopped(self): """Test getMetadata with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), "odt") metadata = handler.getMetadata() self.assertEquals(metadata.get("Title"), "title") self.assertEquals(metadata.get("MIMEType"), "application/vnd.oasis.opendocument.text")
def testConvertWithOpenOfficeStopped(self): """Test convert with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), 'doc') doc_exported = handler.convert("odt") self._assert_document_output( doc_exported, "application/vnd.oasis.opendocument.text")
def testGetMetadata(self): """Test getMetadata""" data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), "odt") metadata = handler.getMetadata() self.assertEquals(metadata.get("MIMEType"), "application/vnd.oasis.opendocument.text") handler.document.restoreOriginal() metadata = handler.getMetadata(True) self.assertNotEquals(metadata.get("Data"), "")
def testGetMetadataWithOpenOfficeStopped(self): """Test getMetadata with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt') metadata = handler.getMetadata() self.assertEquals(metadata.get('Title'), 'title') self.assertEquals(metadata.get('MIMEType'), 'application/vnd.oasis.opendocument.text')
def testSetMetadataWithOpenOfficeStopped(self): """Test setMetadata with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), "doc") new_data = handler.setMetadata({"Title": "cloudooo Test -"}) new_handler = Handler(self.tmp_url, new_data, "doc") metadata = new_handler.getMetadata() self.assertEquals(metadata.get("Title"), "cloudooo Test -")
def testConvertDocToOdt(self): """Test convert DOC to ODT""" data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), 'doc') doc_exported = handler.convert("odt") self._assert_document_output(doc_exported, "application/vnd.oasis.opendocument.text")
def testGetMetadata(self): """Test getMetadata""" data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt') metadata = handler.getMetadata() self.assertEquals(metadata.get('MIMEType'), 'application/vnd.oasis.opendocument.text') handler.document.restoreOriginal() metadata = handler.getMetadata(True) self.assertNotEquals(metadata.get('Data'), '')
def testGetAllowedConversionFormatList_TextCsv(self): """Test allowed conversion format for text/csv""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("text/csv;ignored=param")), [ ('application/msword', 'Microsoft Word 97-2003'), ('application/pdf', 'PDF - Portable Document Format'), ('application/rtf', 'Rich Text'), ('application/vnd.ms-excel', 'Microsoft Excel 97-2003'), ('application/vnd.ms-excel.sheet.macroEnabled.12', 'Microsoft Excel 2007-2016 XML (macro enabled)'), ('application/vnd.oasis.opendocument.spreadsheet', 'ODF Spreadsheet'), ('application/vnd.oasis.opendocument.text', 'ODF Text Document'), ('application/vnd.oasis.opendocument.text', 'Text (Writer/Web)'), ('application/vnd.oasis.opendocument.text-flat-xml', 'Flat XML ODF Text Document'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Microsoft Excel 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Office Open XML Spreadsheet'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Microsoft Word 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Office Open XML Text'), ('application/vnd.sun.xml.writer', 'OpenOffice.org 1.0 Text Document (Writer/Web)'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('text/html', 'HTML Document'), ('text/html', 'HTML Document (Calc)'), ('text/html', 'HTML Document (Writer)'), ('text/plain', 'Text (Writer/Web)'), ('text/plain', 'Text - Choose Encoding'), ('text/plain', 'Text - Choose Encoding (Writer/Web)') ])
def testGetAllowedConversionFormatList_ApplicationVndMsPowerpoint(self): """Test allowed conversion format for application/vnd.ms-powerpoint""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "application/vnd.ms-powerpoint;ignored=param")), [('application/pdf', 'PDF - Portable Document Format'), ('application/postscript', 'EPS - Encapsulated PostScript'), ('application/vnd.ms-powerpoint', 'Microsoft PowerPoint 97-2003'), ('application/vnd.ms-powerpoint', 'Microsoft PowerPoint 97-2003 AutoPlay'), ('application/vnd.oasis.opendocument.graphics', 'ODF Drawing (Impress)'), ('application/vnd.oasis.opendocument.presentation', 'ODF Presentation'), ('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'Microsoft PowerPoint 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'Office Open XML Presentation'), ('application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'Microsoft PowerPoint 2007-2013 XML AutoPlay'), ('application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'Office Open XML Presentation AutoPlay'), ('image/gif', 'GIF - Graphics Interchange Format'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('image/svg+xml', 'SVG - Scalable Vector Graphics'), ('image/tiff', 'TIFF - Tagged Image File Format'), ('image/x-ms-bmp', 'BMP - Windows Bitmap'), ('text/html', 'HTML Document (Impress)')])
def testGetAllowedConversionFormatList_ApplicationVndMsPowerpoint(self): """Test allowed conversion format for application/vnd.ms-powerpoint""" self.maxDiff = None self.assertEquals( sorted(Handler.getAllowedConversionFormatList("application/vnd.ms-powerpoint;ignored=param")), [ ('application/pdf', 'PDF - Portable Document Format'), ('application/postscript', 'EPS - Encapsulated PostScript'), ('application/vnd.oasis.opendocument.graphics', 'ODF Drawing (Impress)'), ('application/vnd.oasis.opendocument.presentation', 'ODF Presentation'), ('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'Microsoft PowerPoint 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'Office Open XML Presentation'), ('application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'Microsoft PowerPoint 2007-2013 XML AutoPlay'), ('application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'Office Open XML Presentation AutoPlay'), ('image/gif', 'GIF - Graphics Interchange Format'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('image/svg+xml', 'SVG - Scalable Vector Graphics'), ('image/tiff', 'TIFF - Tagged Image File Format'), ('image/x-cmu-raster', 'RAS - Sun Raster Image'), ('image/x-ms-bmp', 'BMP - Windows Bitmap'), ('image/x-portable-bitmap', 'PBM - Portable Bitmap'), ('image/x-portable-graymap', 'PGM - Portable Graymap'), ('image/x-portable-pixmap', 'PPM - Portable Pixelmap'), ('image/x-xpixmap', 'XPM - X PixMap'), ('text/html', 'HTML Document (Impress)') ])
def testGetAllowedConversionFormatList_ApplicationVndMsExcelSheetMacroenabled12( self): """Test allowed conversion format for application/vnd.ms-excel.sheet.macroEnabled.12""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "application/vnd.ms-excel.sheet.macroEnabled.12;ignored=param" )), [])
def testGetAllowedConversionFormatList_ApplicationVndOasisOpendocumentTextFlatXml( self): """Test allowed conversion format for application/vnd.oasis.opendocument.text-flat-xml""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "application/vnd.oasis.opendocument.text-flat-xml;ignored=param" )), [])
def testGetAllowedConversionFormatList_ApplicationVndOpenXmlFormatsOfficedocumentSpreadsheetmlSheet(self): """Test allowed conversion format for application/vnd.openxmlformats-officedocument.spreadsheetml.sheet""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;ignored=param")), [ ('application/pdf', 'PDF - Portable Document Format'), ('application/vnd.ms-excel', 'Microsoft Excel 97-2003'), ('application/vnd.ms-excel.sheet.macroEnabled.12', 'Microsoft Excel 2007-2016 XML (macro enabled)'), ('application/vnd.oasis.opendocument.spreadsheet', 'ODF Spreadsheet'), ('image/png', 'PNG - Portable Network Graphic'), ('text/csv', 'Text CSV'), ('text/html', 'HTML Document (Calc)') ])
def testSetMetadata(self): """Test setMetadata""" data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), "odt") new_data = handler.setMetadata({"Title": "cloudooo Test -"}) new_handler = Handler(self.tmp_url, new_data, "odt") metadata = new_handler.getMetadata() self.assertEquals(metadata.get("Title"), "cloudooo Test -") handler = Handler(self.tmp_url, decodestring(data), "odt") new_data = handler.setMetadata({"Title": "Namie's working record"}) new_handler = Handler(self.tmp_url, new_data, "odt") metadata = new_handler.getMetadata() self.assertEquals(metadata.get("Title"), "Namie's working record")
def testRefreshOdt(self): """Test refresh argument""" # Check when refreshing is disabled data = encodestring(open("data/test_fields.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt', refresh=False) doc_exported = handler.convert("odt") document_output_url = path.join(self.tmp_url, "testExport.odt") self._save_document(document_output_url, doc_exported) zip_handler = ZipFile(document_output_url) content_tree = etree.fromstring(zip_handler.read('content.xml')) self.assertFalse( content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]', namespaces=content_tree.nsmap)) # Check when refreshing is enabled data = encodestring(open("data/test_fields.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt', refresh=True) doc_exported = handler.convert("odt") document_output_url = path.join(self.tmp_url, "testExport.odt") self._save_document(document_output_url, doc_exported) zip_handler = ZipFile(document_output_url) content_tree = etree.fromstring(zip_handler.read('content.xml')) self.assertTrue( content_tree.xpath('//text:variable-get[text() = "DISPLAY ME"]', namespaces=content_tree.nsmap))
def testGetAllowedConversionFormatList_ApplicationVndOpenxmlformatsOfficedocumentWordprocessingmlDocument(self): """Test allowed conversion format for application/vnd.openxmlformats-officedocument.wordprocessingml.document""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("application/vnd.openxmlformats-officedocument.wordprocessingml.document;ignored=param")), [ ('application/msword', 'Microsoft Word 97-2003'), ('application/pdf', 'PDF - Portable Document Format'), ('application/rtf', 'Rich Text'), ('application/vnd.oasis.opendocument.text', 'ODF Text Document'), ('application/vnd.oasis.opendocument.text-flat-xml', 'Flat XML ODF Text Document'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('text/html', 'HTML Document (Writer)'), ('text/plain', 'Text - Choose Encoding') ])
def testSetMetadataWithOpenOfficeStopped(self): """Test setMetadata with openoffice stopped""" openoffice.stop() data = encodestring(open("data/test.doc").read()) handler = Handler(self.tmp_url, decodestring(data), 'doc') new_data = handler.setMetadata({"Title": "cloudooo Test -"}) new_handler = Handler(self.tmp_url, new_data, 'doc') metadata = new_handler.getMetadata() self.assertEquals(metadata.get('Title'), "cloudooo Test -")
def testGetAllowedConversionFormatList_ImageXXpixmap(self): """Test allowed conversion format for image/x-xpixmap""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "image/x-xpixmap;ignored=param")), [('application/pdf', 'PDF - Portable Document Format'), ('application/postscript', 'EPS - Encapsulated PostScript'), ('application/vnd.oasis.opendocument.graphics', 'ODF Drawing'), ('image/gif', 'GIF - Graphics Interchange Format'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('image/svg+xml', 'SVG - Scalable Vector Graphics'), ('image/tiff', 'TIFF - Tagged Image File Format'), ('image/x-ms-bmp', 'BMP - Windows Bitmap'), ('text/html', 'HTML Document (Draw)')])
def testGetAllowedConversionFormatList_ImageXXpixmap(self): """Test allowed conversion format for image/x-xpixmap""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("image/x-xpixmap;ignored=param")), [ ('application/pdf', 'PDF - Portable Document Format'), ('application/postscript', 'EPS - Encapsulated PostScript'), ('application/vnd.oasis.opendocument.graphics', 'ODF Drawing'), ('image/gif', 'GIF - Graphics Interchange Format'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('image/svg+xml', 'SVG - Scalable Vector Graphics'), ('image/tiff', 'TIFF - Tagged Image File Format'), ('image/x-cmu-raster', 'RAS - Sun Raster Image'), ('image/x-ms-bmp', 'BMP - Windows Bitmap'), ('image/x-portable-bitmap', 'PBM - Portable Bitmap'), ('image/x-portable-graymap', 'PGM - Portable Graymap'), ('image/x-portable-pixmap', 'PPM - Portable Pixelmap'), ('text/html', 'HTML Document (Draw)') ])
def testGetAllowedConversionFormatList_ApplicationVndMsExcel(self): """Test allowed conversion format for application/vnd.ms-excel""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "application/vnd.ms-excel;ignored=param")), [('application/pdf', 'PDF - Portable Document Format'), ('application/vnd.ms-excel', 'Microsoft Excel 97-2003'), ('application/vnd.ms-excel.sheet.macroEnabled.12', 'Microsoft Excel 2007-2016 XML (macro enabled)'), ('application/vnd.oasis.opendocument.spreadsheet', 'ODF Spreadsheet'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Microsoft Excel 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Office Open XML Spreadsheet'), ('image/png', 'PNG - Portable Network Graphic'), ('text/csv', 'Text CSV'), ('text/html', 'HTML Document (Calc)')])
def testGetAllowedConversionFormatList_ApplicationVndSunXmlWriter(self): """Test allowed conversion format for application/vnd.sun.xml.writer""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "application/vnd.sun.xml.writer;ignored=param")), [('application/msword', 'Microsoft Word 97-2003'), ('application/pdf', 'PDF - Portable Document Format'), ('application/rtf', 'Rich Text'), ('application/vnd.oasis.opendocument.text', 'ODF Text Document'), ('application/vnd.oasis.opendocument.text-flat-xml', 'Flat XML ODF Text Document'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Microsoft Word 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Office Open XML Text'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('text/html', 'HTML Document (Writer)'), ('text/plain', 'Text - Choose Encoding')])
def testGetAllowedConversionFormatList_TextCsv(self): """Test allowed conversion format for text/csv""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "text/csv;ignored=param")), [('application/msword', 'Microsoft Word 97-2003'), ('application/pdf', 'PDF - Portable Document Format'), ('application/rtf', 'Rich Text'), ('application/vnd.ms-excel', 'Microsoft Excel 97-2003'), ('application/vnd.ms-excel.sheet.macroEnabled.12', 'Microsoft Excel 2007-2016 XML (macro enabled)'), ('application/vnd.oasis.opendocument.spreadsheet', 'ODF Spreadsheet'), ('application/vnd.oasis.opendocument.text', 'ODF Text Document'), ('application/vnd.oasis.opendocument.text', 'Text (Writer/Web)'), ('application/vnd.oasis.opendocument.text-flat-xml', 'Flat XML ODF Text Document'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Microsoft Excel 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Office Open XML Spreadsheet'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Microsoft Word 2007-2013 XML'), ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Office Open XML Text'), ('application/vnd.sun.xml.writer', 'OpenOffice.org 1.0 Text Document (Writer/Web)'), ('image/jpeg', 'JPEG - Joint Photographic Experts Group'), ('image/png', 'PNG - Portable Network Graphic'), ('text/csv', 'Text CSV'), ('text/html', 'HTML Document'), ('text/html', 'HTML Document (Calc)'), ('text/html', 'HTML Document (Writer)'), ('text/plain', 'Text (Writer/Web)'), ('text/plain', 'Text - Choose Encoding'), ('text/plain', 'Text - Choose Encoding (Writer/Web)')])
def testGetAllowedConversionFormatList_ApplicationVndOasisOpendocumentTextFlatXml(self): """Test allowed conversion format for application/vnd.oasis.opendocument.text-flat-xml""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("application/vnd.oasis.opendocument.text-flat-xml;ignored=param")), [])
def convert(self, destination_format=None, **kw): """ Convert the inputed file to output as format that were informed """ source_format = self.file.source_format logger.debug("x2t convert: %s > %s" % (source_format, destination_format)) # init vars and xml configuration file in_format = format_code_map[source_format] out_format = format_code_map_output.get(destination_format, format_code_map[destination_format]) root_dir = self.file.directory_name input_dir = os.path.join(root_dir, "input"); input_file_name = self.file.getUrl() output_file_name = os.path.join(root_dir, "document.%s" % destination_format) config_file_name = os.path.join(root_dir, "config.xml") metadata = None output_data = None if source_format in yformat_tuple: if self._data.startswith("PK\x03\x04"): os.mkdir(input_dir) unzip(self.file.getUrl(), input_dir) input_file_name = os.path.join(input_dir, "body.txt") if not os.path.isfile(input_file_name): input_file_name = os.path.join(input_dir, "Editor.bin") if not os.path.isfile(input_file_name): raise RuntimeError("input format incorrect: Editor.bin absent in zip archive") metadata_file_name = os.path.join(input_dir, "metadata.json") if os.path.isfile(metadata_file_name): with open(metadata_file_name) as metadata_file: metadata = json.loads(metadata_file.read()) with open(config_file_name, "w") as config_file: config = { # 'm_sKey': 'from', 'm_sFileFrom': input_file_name, 'm_nFormatFrom': str(in_format), 'm_sFileTo': output_file_name, 'm_nFormatTo': str(out_format), # 'm_bPaid': 'true', # 'm_bEmbeddedFonts': 'false', # 'm_bFromChanges': 'false', # 'm_sFontDir': '/usr/share/fonts', # 'm_sThemeDir': '/var/www/onlyoffice/documentserver/FileConverterService/presentationthemes', } root = ElementTree.Element('root') for key, value in config.items(): ElementTree.SubElement(root, key).text = value ElementTree.ElementTree(root).write(config_file, encoding='utf-8', xml_declaration=True, default_namespace=None, method="xml") # run convertion binary p = Popen( ["x2t", config_file.name], stdout=PIPE, stderr=PIPE, close_fds=True, env=self.environment, ) stdout, stderr = p.communicate() if p.returncode != 0: raise RuntimeError("x2t: exit code %d != 0\n+ %s\n> stdout: %s\n> stderr: %s@ x2t xml:\n%s" % (p.returncode, " ".join(["x2t", config_file.name]), stdout, stderr, " " + open(config_file.name).read().replace("\n", "\n "))) self.file.reload(output_file_name) try: if source_format in yformat_tuple: if metadata: output_data = OOoHandler(self.base_folder_url, self.file.getContent(), source_format, **self._init_kw)\ .setMetadata(metadata) else: output_data = self.file.getContent() elif destination_format in yformat_tuple: if not metadata: if source_format not in yformat_tuple: metadata = OOoHandler(self.base_folder_url, self._data, source_format, **self._init_kw).getMetadata() if not metadata: metadata = {} metadata.pop('MIMEType', None) metadata.pop('Generator', None) metadata.pop('AppVersion', None) metadata.pop('ImplementationName', None) with ZipFile(output_file_name, mode="a") as zipfile: zipfile.writestr("metadata.json", json.dumps(metadata)) output_data = self.file.getContent() finally: self.file.trash() return output_data
def testGetAllowedConversionFormatList_ApplicationVndMsExcelSheetMacroenabled12(self): """Test allowed conversion format for application/vnd.ms-excel.sheet.macroEnabled.12""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("application/vnd.ms-excel.sheet.macroEnabled.12;ignored=param")), [])
def testGetAllowedConversionFormatList_TextRtf(self): """Test allowed conversion format for text/rtf""" self.assertEquals( sorted( Handler.getAllowedConversionFormatList( "text/rtf;ignored=param")), [])
def get(*args, **kw): return sorted(Handler.getAllowedConversionFormatList(*args, **kw))
def testGetAllowedConversionFormatList_TextRtf(self): """Test allowed conversion format for text/rtf""" self.assertEquals( sorted(Handler.getAllowedConversionFormatList("text/rtf;ignored=param")), [])
def testSetMetadata(self): """Test setMetadata""" data = encodestring(open("data/test.odt").read()) handler = Handler(self.tmp_url, decodestring(data), 'odt') new_data = handler.setMetadata({"Title": "cloudooo Test -"}) new_handler = Handler(self.tmp_url, new_data, 'odt') metadata = new_handler.getMetadata() self.assertEquals(metadata.get('Title'), "cloudooo Test -") handler = Handler(self.tmp_url, decodestring(data), 'odt') new_data = handler.setMetadata({"Title": "Namie's working record"}) new_handler = Handler(self.tmp_url, new_data, 'odt') metadata = new_handler.getMetadata() self.assertEquals(metadata.get('Title'), "Namie's working record")