@@ -341,6 +341,37 @@ def _params_with_dataframe(*args, **kwargs):
341341 assert value_a == value_b # same content --> same key
342342
343343
344+ @pytest .mark .mongo
345+ def test_mongo_core_ensure_collection_collection_set_not_verified ():
346+ """Cover line 69 False branch: collection already set when entering lock."""
347+ core = _MongoCore (hash_func = None , mongetter = _test_mongetter , wait_for_calc_timeout = 10 )
348+ core .set_func (lambda x : x )
349+
350+ # Set mongo_collection manually so it is not None, but leave _index_verified as False.
351+ # Outer guard: mongo_collection is not None AND _index_verified is False → enters lock.
352+ # Line 69: False (collection already set) → skips fetching collection.
353+ # Line 72: True (not verified) → verifies index.
354+ core .mongo_collection = _test_mongetter ()
355+ collection = core ._ensure_collection ()
356+ assert collection is not None
357+ assert core ._index_verified is True
358+
359+
360+ @pytest .mark .mongo
361+ def test_mongo_core_ensure_collection_index_verified_inside_lock ():
362+ """Cover line 72 False branch: _index_verified is True when inside lock."""
363+ core = _MongoCore (hash_func = None , mongetter = _test_mongetter , wait_for_calc_timeout = 10 )
364+ core .set_func (lambda x : x )
365+
366+ # Set _index_verified = True, but leave mongo_collection as None.
367+ # Outer guard: mongo_collection is None → enters lock.
368+ # Line 69: True (collection is None) → fetches collection.
369+ # Line 72: False (_index_verified is already True) → skips index check.
370+ core ._index_verified = True
371+ collection = core ._ensure_collection ()
372+ assert collection is not None
373+
374+
344375@pytest .mark .mongo
345376def test_mongo_core_set_entry_should_not_store ():
346377 core = _MongoCore (hash_func = None , mongetter = _test_mongetter , wait_for_calc_timeout = 10 )
0 commit comments