コード例 #1
0
    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))
コード例 #2
0
  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))
コード例 #3
0
 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")
コード例 #4
0
ファイル: testOooHandler.py プロジェクト: nsi-iff/cloudooo
 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")
コード例 #5
0
 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")
コード例 #6
0
 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")
コード例 #7
0
 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")
コード例 #8
0
 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")