|
4 | 4 |
|
5 | 5 | import pytest
|
6 | 6 |
|
| 7 | +from docx.comments import Comments |
7 | 8 | from docx.enum.style import WD_STYLE_TYPE
|
8 | 9 | from docx.opc.constants import CONTENT_TYPE as CT
|
9 | 10 | from docx.opc.constants import RELATIONSHIP_TYPE as RT
|
10 | 11 | from docx.opc.coreprops import CoreProperties
|
11 | 12 | from docx.opc.packuri import PackURI
|
12 | 13 | from docx.package import Package
|
| 14 | +from docx.parts.comments import CommentsPart |
13 | 15 | from docx.parts.document import DocumentPart
|
14 | 16 | from docx.parts.hdrftr import FooterPart, HeaderPart
|
15 | 17 | from docx.parts.numbering import NumberingPart
|
@@ -109,6 +111,17 @@ def it_can_save_the_package_to_a_file(self, package_: Mock):
|
109 | 111 |
|
110 | 112 | package_.save.assert_called_once_with("foobar.docx")
|
111 | 113 |
|
| 114 | + def it_provides_access_to_the_comments_added_to_the_document( |
| 115 | + self, _comments_part_prop_: Mock, comments_part_: Mock, comments_: Mock, package_: Mock |
| 116 | + ): |
| 117 | + comments_part_.comments = comments_ |
| 118 | + _comments_part_prop_.return_value = comments_part_ |
| 119 | + document_part = DocumentPart( |
| 120 | + PackURI("/word/document.xml"), CT.WML_DOCUMENT, element("w:document"), package_ |
| 121 | + ) |
| 122 | + |
| 123 | + assert document_part.comments is comments_ |
| 124 | + |
112 | 125 | def it_provides_access_to_the_document_settings(
|
113 | 126 | self, _settings_part_prop_: Mock, settings_part_: Mock, settings_: Mock, package_: Mock
|
114 | 127 | ):
|
@@ -282,6 +295,22 @@ def and_it_creates_a_default_styles_part_if_not_present(
|
282 | 295 |
|
283 | 296 | # -- fixtures --------------------------------------------------------------------------------
|
284 | 297 |
|
| 298 | + @pytest.fixture |
| 299 | + def comments_(self, request: FixtureRequest) -> Mock: |
| 300 | + return instance_mock(request, Comments) |
| 301 | + |
| 302 | + @pytest.fixture |
| 303 | + def CommentsPart_(self, request: FixtureRequest) -> Mock: |
| 304 | + return class_mock(request, "docx.parts.document.CommentsPart") |
| 305 | + |
| 306 | + @pytest.fixture |
| 307 | + def comments_part_(self, request: FixtureRequest) -> Mock: |
| 308 | + return instance_mock(request, CommentsPart) |
| 309 | + |
| 310 | + @pytest.fixture |
| 311 | + def _comments_part_prop_(self, request: FixtureRequest) -> Mock: |
| 312 | + return property_mock(request, DocumentPart, "_comments_part") |
| 313 | + |
285 | 314 | @pytest.fixture
|
286 | 315 | def core_properties_(self, request: FixtureRequest):
|
287 | 316 | return instance_mock(request, CoreProperties)
|
|
0 commit comments