@@ -121,6 +121,15 @@ def but_it_raises_KeyError_when_no_bookmark_by_that_name(self, bookmark_, _iter_
121121 bookmarks .get ("barfoo" )
122122 assert e .value .args [0 ] == "Requested bookmark not found."
123123
124+ def it_knows_the_next_available_bookmark_id (self , next_id_fixture , _iter_ ):
125+ mock_bookmarks , expected_value = next_id_fixture
126+ _iter_ .return_value = iter (mock_bookmarks )
127+ bookmarks = Bookmarks (None )
128+
129+ next_id = bookmarks .next_id
130+
131+ assert next_id is expected_value
132+
124133 def it_provides_access_to_its_bookmark_finder_to_help (
125134 self , document_part_ , _DocumentBookmarkFinder_ , finder_
126135 ):
@@ -151,6 +160,14 @@ def contains_fixture(self, request):
151160 bookmark_ .name = member_names [idx ]
152161 return mock_bookmarks , name , expected_value
153162
163+ @pytest .fixture (params = [((), 1 ), ((1 , 2 , 3 ), 4 ), ((1 , 3 ), 4 ), ((2 , 42 ), 43 )])
164+ def next_id_fixture (self , request ):
165+ bookmark_ids , expected_value = request .param
166+ mock_bookmarks = tuple (
167+ instance_mock (request , _Bookmark , id = bmid ) for bmid in bookmark_ids
168+ )
169+ return mock_bookmarks , expected_value
170+
154171 # fixture components ---------------------------------------------
155172
156173 @pytest .fixture
0 commit comments