Example #1
0
    def test_docx_file(self):
        content = self.get_content('hello_world.docx')

        docx = DocxFile(content)

        for text in [u'Hello world ', u'this is a link']:
            self.assertTrue(text in docx.get_document())

        for url in [u'https://www.transifex.com/']:
            self.assertTrue(url in docx.get_document_rels())

        docx.set_document(u'Modified Document')
        docx.set_document_rels(u'Modified Document Rels')

        content = docx.compress()
        docx.delete()

        docx = DocxFile(content)
        self.assertEqual(docx.get_document(), u'Modified Document')
        self.assertEqual(docx.get_document_rels(), u'Modified Document Rels')
Example #2
0
    def test_docx_file(self):
        path = '{}/hello_world.docx'.format(self.TESTFILE_BASE)
        with open(path, 'rb') as f:
            content = f.read()

        docx = DocxFile(content)

        for text in [u'Hello world ', u'this is a link']:
            self.assertTrue(text in docx.get_document())

        for url in [u'https://www.transifex.com/']:
            self.assertTrue(url in docx.get_document_rels())

        docx.set_document(u'Modified Document')
        docx.set_document_rels(u'Modified Document Rels')

        content = docx.compress()
        docx.delete()

        docx = DocxFile(content)
        self.assertEqual(docx.get_document(), u'Modified Document')
        self.assertEqual(docx.get_document_rels(), u'Modified Document Rels')