Skip to content

Commit 82737b1

Browse files
Test RTF file conversion
1 parent 21e2b81 commit 82737b1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cardinal_pythonlib/tests/extract_text_tests.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,33 @@ def test_pdf_converted(self) -> None:
232232
),
233233
]
234234
self.mock_popen.assert_has_calls(expected_calls)
235+
236+
def test_rtf_converted(self) -> None:
237+
with mock.patch(
238+
"cardinal_pythonlib.extract_text.UNRTF_SUPPORTS_QUIET", True
239+
):
240+
with mock.patch.multiple(
241+
"cardinal_pythonlib.extract_text.subprocess",
242+
Popen=self.mock_popen,
243+
):
244+
with NamedTemporaryFile(
245+
suffix=".rtf", delete=False
246+
) as temp_file:
247+
temp_file.close()
248+
document_to_text(
249+
filename=temp_file.name, config=self.config
250+
)
251+
252+
expected_calls = [
253+
mock.call(
254+
(
255+
f"{self.empty_dir}/unrtf",
256+
"--text",
257+
"--nopict",
258+
"--quiet",
259+
temp_file.name,
260+
),
261+
stdout=subprocess.PIPE,
262+
),
263+
]
264+
self.mock_popen.assert_has_calls(expected_calls)

0 commit comments

Comments
 (0)