|
15 | 15 | from docx.parts.document import DocumentPart |
16 | 16 | from docx.parts.image import ImagePart |
17 | 17 | from docx.parts.numbering import NumberingPart |
| 18 | +from docx.parts.settings import SettingsPart |
18 | 19 | from docx.parts.styles import StylesPart |
| 20 | +from docx.settings import Settings |
19 | 21 | from docx.styles.style import BaseStyle |
20 | 22 | from docx.styles.styles import Styles |
21 | 23 | from docx.text.paragraph import Paragraph |
@@ -45,6 +47,11 @@ def it_can_get_or_add_an_image(self, get_image_fixture): |
45 | 47 | document_part.relate_to.assert_called_once_with(image_part_, RT.IMAGE) |
46 | 48 | assert (rId, image) == (rId_, image_) |
47 | 49 |
|
| 50 | + def it_provides_access_to_the_document_settings(self, settings_fixture): |
| 51 | + document_part, settings_ = settings_fixture |
| 52 | + settings = document_part.settings |
| 53 | + assert settings is settings_ |
| 54 | + |
48 | 55 | def it_provides_access_to_the_document_styles(self, styles_fixture): |
49 | 56 | document_part, styles_ = styles_fixture |
50 | 57 | styles = document_part.styles |
@@ -217,6 +224,14 @@ def save_fixture(self, package_): |
217 | 224 | file_ = 'foobar.docx' |
218 | 225 | return document_part, file_ |
219 | 226 |
|
| 227 | + @pytest.fixture |
| 228 | + def settings_fixture(self, _settings_part_prop_, settings_part_, |
| 229 | + settings_): |
| 230 | + document_part = DocumentPart(None, None, None, None) |
| 231 | + _settings_part_prop_.return_value = settings_part_ |
| 232 | + settings_part_.settings = settings_ |
| 233 | + return document_part, settings_ |
| 234 | + |
220 | 235 | @pytest.fixture |
221 | 236 | def styles_fixture(self, _styles_part_prop_, styles_part_, styles_): |
222 | 237 | document_part = DocumentPart(None, None, None, None) |
@@ -289,6 +304,18 @@ def part_related_by_(self, request): |
289 | 304 | def relate_to_(self, request): |
290 | 305 | return method_mock(request, DocumentPart, 'relate_to') |
291 | 306 |
|
| 307 | + @pytest.fixture |
| 308 | + def settings_(self, request): |
| 309 | + return instance_mock(request, Settings) |
| 310 | + |
| 311 | + @pytest.fixture |
| 312 | + def settings_part_(self, request): |
| 313 | + return instance_mock(request, SettingsPart) |
| 314 | + |
| 315 | + @pytest.fixture |
| 316 | + def _settings_part_prop_(self, request): |
| 317 | + return property_mock(request, DocumentPart, '_settings_part') |
| 318 | + |
292 | 319 | @pytest.fixture |
293 | 320 | def style_(self, request): |
294 | 321 | return instance_mock(request, BaseStyle) |
|
0 commit comments