-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import docx | ||
|
||
from ragna.core import DocxDocumentHandler, LocalDocument | ||
|
||
|
||
def get_docx_document(tmp_path, docx_text): | ||
document = docx.Document() | ||
document.add_heading(docx_text) | ||
document.add_paragraph(docx_text) | ||
path = tmp_path / "test_document.docx" | ||
document.save(path) | ||
return LocalDocument.from_path(path) | ||
|
||
|
||
def test_docx(tmp_path): | ||
docx_text = "ragna is neat!" | ||
tmp_docx_document = get_docx_document(tmp_path, docx_text) | ||
assert isinstance(tmp_docx_document.handler, DocxDocumentHandler) | ||
pages = list(tmp_docx_document.extract_pages()) | ||
assert len(pages) == 2 | ||
for page in pages: | ||
assert page.text == docx_text |