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 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 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 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 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 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")