-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtest_openxml_differ.py
More file actions
40 lines (28 loc) · 1.15 KB
/
test_openxml_differ.py
File metadata and controls
40 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import pytest
from unittest.mock import patch, MagicMock
from python_redlines.engines import XmlPowerToolsEngine
def load_docx_bytes(file_path):
# Handle relative paths from test directory
if not os.path.isabs(file_path):
file_path = os.path.join(os.path.dirname(__file__), file_path)
with open(file_path, 'rb') as file:
return file.read()
@pytest.fixture
def original_docx():
return load_docx_bytes('fixtures/original.docx')
@pytest.fixture
def modified_docx():
return load_docx_bytes('fixtures/modified.docx')
def test_run_redlines_with_real_files(original_docx, modified_docx):
# Create an instance of the wrapper
wrapper = XmlPowerToolsEngine()
author_tag = "TestAuthor"
# Running the wrapper function with actual file bytes
redline_output, stdout, stderr = wrapper.run_redline(author_tag, original_docx, modified_docx)
# Asserting that some output is generated (specific assertions depend on expected output)
assert redline_output is not None
assert isinstance(redline_output, bytes)
assert len(redline_output) > 0
assert stderr is None
assert "Revisions found: 9" in stdout