1616
1717class DescribeSection (object ):
1818
19- def it_knows_its_start_type (self , start_type_fixture ):
20- section , expected_start_type = start_type_fixture
19+ def it_knows_its_start_type (self , start_type_get_fixture ):
20+ section , expected_start_type = start_type_get_fixture
2121 assert section .start_type is expected_start_type
2222
23+ def it_can_change_its_start_type (self , start_type_set_fixture ):
24+ section , new_start_type , expected_xml = start_type_set_fixture
25+ section .start_type = new_start_type
26+ assert section ._sectPr .xml == expected_xml
27+
2328 # fixtures -------------------------------------------------------
2429
2530 @pytest .fixture (params = [
@@ -30,11 +35,31 @@ def it_knows_its_start_type(self, start_type_fixture):
3035 ('evenPage' , WD_SECTION .EVEN_PAGE ),
3136 ('nextColumn' , WD_SECTION .NEW_COLUMN ),
3237 ])
33- def start_type_fixture (self , request ):
38+ def start_type_get_fixture (self , request ):
3439 type_val , expected_start_type = request .param
35- sectPr_bldr = a_sectPr ().with_nsdecls ()
36- if type_val is not None :
37- sectPr_bldr .with_child (a_type ().with_val (type_val ))
38- sectPr = sectPr_bldr .element
40+ sectPr = self .sectPr_bldr (type_val ).element
3941 section = Section (sectPr )
4042 return section , expected_start_type
43+
44+ @pytest .fixture (params = [
45+ ('oddPage' , WD_SECTION .EVEN_PAGE , 'evenPage' ),
46+ ('nextPage' , None , None ),
47+ ('continuous' , WD_SECTION .NEW_PAGE , None ),
48+ (None , WD_SECTION .NEW_COLUMN , 'nextColumn' ),
49+ ])
50+ def start_type_set_fixture (self , request ):
51+ initial_type_val , new_type , expected_type_val = request .param
52+ sectPr = self .sectPr_bldr (initial_type_val ).element
53+ section = Section (sectPr )
54+ expected_xml = self .sectPr_bldr (expected_type_val ).xml ()
55+ return section , new_type , expected_xml
56+
57+ # fixture components ---------------------------------------------
58+
59+ def sectPr_bldr (self , start_type = None ):
60+ sectPr_bldr = a_sectPr ().with_nsdecls ()
61+ if start_type is not None :
62+ sectPr_bldr .with_child (
63+ a_type ().with_val (start_type )
64+ )
65+ return sectPr_bldr
0 commit comments