Skip to content

Commit 3c06e1c

Browse files
author
Steve Canny
committed
test: refactor tests.test_shape to use cxml
1 parent 574fea1 commit 3c06e1c

1 file changed

Lines changed: 30 additions & 33 deletions

File tree

tests/test_shape.py

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
an_spPr, an_xfrm
2222
)
2323
from .oxml.unitdata.text import an_r
24+
from .unitutil.cxml import element, xml
2425
from .unitutil.mock import instance_mock
2526

2627

@@ -58,37 +59,21 @@ def it_can_change_its_display_dimensions(self, dimensions_set_fixture):
5859

5960
@pytest.fixture
6061
def dimensions_get_fixture(self):
61-
cx, cy = 333, 666
62-
inline = self._inline_bldr_with_dimensions(cx, cy).element
63-
inline_shape = InlineShape(inline)
64-
return inline_shape, cx, cy
62+
inline_cxml, expected_cx, expected_cy = (
63+
'wp:inline/wp:extent{cx=333, cy=666}', 333, 666
64+
)
65+
inline_shape = InlineShape(element(inline_cxml))
66+
return inline_shape, expected_cx, expected_cy
6567

6668
@pytest.fixture
6769
def dimensions_set_fixture(self):
68-
# inline_shape -----------------
69-
cx, cy = 333, 666
70-
inline = self._inline_bldr_with_dimensions(cx, cy).element
71-
inline_shape = InlineShape(inline)
72-
# expected_xml -----------------
73-
cx, cy = cx + 111, cy + 222
74-
expected_xml = self._inline_bldr_with_dimensions(cx, cy).xml()
75-
return inline_shape, cx, cy, expected_xml
76-
77-
@pytest.fixture
78-
def image_params(self):
79-
filename = 'foobar.garf'
80-
rId = 'rId42'
81-
cx, cy = 914422, 223344
82-
return filename, rId, cx, cy
83-
84-
@pytest.fixture
85-
def image_part_(self, request, image_params):
86-
filename, rId, cx, cy = image_params
87-
image_part_ = instance_mock(request, ImagePart)
88-
image_part_.default_cx = cx
89-
image_part_.default_cy = cy
90-
image_part_.filename = filename
91-
return image_part_
70+
inline_cxml, new_cx, new_cy, expected_cxml = (
71+
'wp:inline/wp:extent{cx=333, cy=666}', 444, 888,
72+
'wp:inline/wp:extent{cx=444, cy=888}'
73+
)
74+
inline_shape = InlineShape(element(inline_cxml))
75+
expected_xml = xml(expected_cxml)
76+
return inline_shape, new_cx, new_cy, expected_xml
9277

9378
@pytest.fixture
9479
def new_picture_fixture(self, request, image_part_, image_params):
@@ -144,11 +129,23 @@ def shape_type_fixture(self, request):
144129

145130
return InlineShape(inline), shape_type
146131

147-
def _inline_bldr_with_dimensions(self, cx, cy):
148-
return (
149-
an_inline().with_nsdecls().with_child(
150-
an_extent().with_cx(cx).with_cy(cy))
151-
)
132+
# fixture components ---------------------------------------------
133+
134+
@pytest.fixture
135+
def image_params(self):
136+
filename = 'foobar.garf'
137+
rId = 'rId42'
138+
cx, cy = 914422, 223344
139+
return filename, rId, cx, cy
140+
141+
@pytest.fixture
142+
def image_part_(self, request, image_params):
143+
filename, rId, cx, cy = image_params
144+
image_part_ = instance_mock(request, ImagePart)
145+
image_part_.default_cx = cx
146+
image_part_.default_cy = cy
147+
image_part_.filename = filename
148+
return image_part_
152149

153150
def _inline_with_picture(self, embed=False, link=False):
154151
picture_ns = nsmap['pic']

0 commit comments

Comments
 (0)