1515 StyleFactory , _TableStyle
1616)
1717
18- from ..unitutil .cxml import element
18+ from ..unitutil .cxml import element , xml
1919from ..unitutil .mock import class_mock , instance_mock
2020
2121
@@ -98,6 +98,11 @@ def it_knows_its_style_id(self, id_get_fixture):
9898 style , expected_value = id_get_fixture
9999 assert style .style_id == expected_value
100100
101+ def it_can_change_its_style_id (self , id_set_fixture ):
102+ style , new_value , expected_xml = id_set_fixture
103+ style .style_id = new_value
104+ assert style ._element .xml == expected_xml
105+
101106 # fixture --------------------------------------------------------
102107
103108 @pytest .fixture (params = [
@@ -108,3 +113,15 @@ def id_get_fixture(self, request):
108113 style_cxml , expected_value = request .param
109114 style = BaseStyle (element (style_cxml ))
110115 return style , expected_value
116+
117+ @pytest .fixture (params = [
118+ ('w:style' , 'Foo' , 'w:style{w:styleId=Foo}' ),
119+ ('w:style{w:styleId=Foo}' , 'Bar' , 'w:style{w:styleId=Bar}' ),
120+ ('w:style{w:styleId=Bar}' , None , 'w:style' ),
121+ ('w:style' , None , 'w:style' ),
122+ ])
123+ def id_set_fixture (self , request ):
124+ style_cxml , new_value , expected_style_cxml = request .param
125+ style = BaseStyle (element (style_cxml ))
126+ expected_xml = xml (expected_style_cxml )
127+ return style , new_value , expected_xml
0 commit comments