1515from docx .parts .story import BaseStoryPart
1616from docx .styles .style import BaseStyle
1717
18+ from ..unitutil .cxml import element
1819from ..unitutil .file import snippet_text
1920from ..unitutil .mock import instance_mock , method_mock , property_mock
2021
@@ -75,6 +76,14 @@ def it_can_create_a_new_pic_inline(self, get_or_add_image_, image_, next_id_prop
7576 image_ .scaled_dimensions .assert_called_once_with (100 , 200 )
7677 assert inline .xml == expected_xml
7778
79+ def it_knows_the_next_available_xml_id (self , next_id_fixture ):
80+ story_element , expected_value = next_id_fixture
81+ story_part = BaseStoryPart (None , None , story_element , None )
82+
83+ next_id = story_part .next_id
84+
85+ assert next_id == expected_value
86+
7887 def it_knows_the_main_document_part_to_help (self , package_ , document_part_ ):
7988 package_ .main_document_part = document_part_
8089 story_part = BaseStoryPart (None , None , None , package_ )
@@ -83,6 +92,26 @@ def it_knows_the_main_document_part_to_help(self, package_, document_part_):
8392
8493 assert document_part is document_part_
8594
95+ # fixtures -------------------------------------------------------
96+
97+ @pytest .fixture (
98+ params = [
99+ (("w:document" ), 1 ),
100+ (("w:document/w:p{id=1}" ), 2 ),
101+ (("w:document/w:p{id=2}" ), 3 ),
102+ (("w:hdr/(w:p{id=1},w:p{id=2},w:p{id=3})" ), 4 ),
103+ (("w:hdr/(w:p{id=1},w:p{id=2},w:p{id=4})" ), 5 ),
104+ (("w:hdr/(w:p{id=0},w:p{id=0})" ), 1 ),
105+ (("w:ftr/(w:p{id=0},w:p{id=0},w:p{id=1},w:p{id=3})" ), 4 ),
106+ (("w:ftr/(w:p{id=foo},w:p{id=1},w:p{id=2})" ), 3 ),
107+ (("w:ftr/(w:p{id=1},w:p{id=bar})" ), 2 ),
108+ ]
109+ )
110+ def next_id_fixture (self , request ):
111+ story_cxml , expected_value = request .param
112+ story_element = element (story_cxml )
113+ return story_element , expected_value
114+
86115 # fixture components ---------------------------------------------
87116
88117 @pytest .fixture
0 commit comments