@@ -186,26 +186,34 @@ class BindGroupAuthorRepository(SQLAlchemyAsyncRepository[Any]):
186186 assert author1 .name == "Test Author"
187187
188188 # Verify default cache was populated
189- cached_default = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
189+ cached_default = memory_cache_manager .get_entity_sync (
190+ table_name , author_id , BindGroupAuthor , bind_group = None
191+ )
190192 assert cached_default is not None
191193
192194 # Get with bind_group="shard_a" - should cache to shard_a key
193195 author2 = await repo .get (author_id , bind_group = "shard_a" )
194196 assert author2 .name == "Test Author"
195197
196198 # Verify shard_a cache was populated
197- cached_shard_a = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
199+ cached_shard_a = memory_cache_manager .get_entity_sync (
200+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
201+ )
198202 assert cached_shard_a is not None
199203
200204 # Invalidate only shard_a cache
201205 memory_cache_manager .invalidate_entity_sync (table_name , author_id , bind_group = "shard_a" )
202206
203207 # Verify default cache still exists
204- cached_default_after = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
208+ cached_default_after = memory_cache_manager .get_entity_sync (
209+ table_name , author_id , BindGroupAuthor , bind_group = None
210+ )
205211 assert cached_default_after is not None , "Default cache should still exist"
206212
207213 # Verify shard_a cache was invalidated
208- cached_shard_a_after = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
214+ cached_shard_a_after = memory_cache_manager .get_entity_sync (
215+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
216+ )
209217 assert cached_shard_a_after is None , "shard_a cache should be invalidated"
210218
211219 finally :
@@ -370,23 +378,33 @@ class BindGroupAuthorRepository(SQLAlchemySyncRepository[Any]):
370378 assert author1 .name == "Test Author"
371379
372380 # Verify default cache was populated
373- cached_default = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
381+ cached_default = memory_cache_manager .get_entity_sync (
382+ table_name , author_id , BindGroupAuthor , bind_group = None
383+ )
374384 assert cached_default is not None
375385
376386 # Get with bind_group="shard_a"
377387 author2 = repo .get (author_id , bind_group = "shard_a" )
378388 assert author2 .name == "Test Author"
379389
380390 # Verify shard_a cache was populated
381- cached_shard_a = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
391+ cached_shard_a = memory_cache_manager .get_entity_sync (
392+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
393+ )
382394 assert cached_shard_a is not None
383395
384396 # Invalidate only shard_a
385397 memory_cache_manager .invalidate_entity_sync (table_name , author_id , bind_group = "shard_a" )
386398
387399 # Verify default still cached, shard_a invalidated
388- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None ) is not None
389- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" ) is None
400+ assert (
401+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
402+ is not None
403+ )
404+ assert (
405+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
406+ is None
407+ )
390408
391409 finally :
392410 BindGroupAuthor .metadata .drop_all (sqlite_engine )
@@ -483,7 +501,9 @@ class BindGroupAuthorRepository(SQLAlchemyAsyncRepository[Any]):
483501 await repo .get (author_id )
484502
485503 # Verify cache was populated for default_shard bind_group
486- cached = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "default_shard" )
504+ cached = memory_cache_manager .get_entity_sync (
505+ table_name , author_id , BindGroupAuthor , bind_group = "default_shard"
506+ )
487507 assert cached is not None , "Cache should use default bind_group from constructor"
488508
489509 # Verify no cache for None bind_group
@@ -539,8 +559,12 @@ class BindGroupAuthorRepository(SQLAlchemyAsyncRepository[Any]):
539559 await repo .get (author_id , bind_group = "override_shard" )
540560
541561 # Verify cache was populated for override_shard, not default_shard
542- cached_override = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "override_shard" )
543- cached_default = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "default_shard" )
562+ cached_override = memory_cache_manager .get_entity_sync (
563+ table_name , author_id , BindGroupAuthor , bind_group = "override_shard"
564+ )
565+ cached_default = memory_cache_manager .get_entity_sync (
566+ table_name , author_id , BindGroupAuthor , bind_group = "default_shard"
567+ )
544568
545569 assert cached_override is not None , "Cache should be for override_shard"
546570 assert cached_default is None , "No cache for default_shard when overridden"
@@ -596,9 +620,15 @@ async def test_cache_manager_entity_methods_with_bind_group(
596620 memory_cache_manager .set_entity_sync (table_name , author_id , author , bind_group = "shard_b" )
597621
598622 # Test get_entity_sync returns correct cached entity per bind_group
599- cached_default = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
600- cached_shard_a = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
601- cached_shard_b = memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_b" )
623+ cached_default = memory_cache_manager .get_entity_sync (
624+ table_name , author_id , BindGroupAuthor , bind_group = None
625+ )
626+ cached_shard_a = memory_cache_manager .get_entity_sync (
627+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
628+ )
629+ cached_shard_b = memory_cache_manager .get_entity_sync (
630+ table_name , author_id , BindGroupAuthor , bind_group = "shard_b"
631+ )
602632
603633 assert cached_default is not None
604634 assert cached_shard_a is not None
@@ -613,9 +643,18 @@ async def test_cache_manager_entity_methods_with_bind_group(
613643 memory_cache_manager .invalidate_entity_sync (table_name , author_id , bind_group = "shard_a" )
614644
615645 # Verify only shard_a was invalidated
616- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None ) is not None
617- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" ) is None
618- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_b" ) is not None
646+ assert (
647+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
648+ is not None
649+ )
650+ assert (
651+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
652+ is None
653+ )
654+ assert (
655+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_b" )
656+ is not None
657+ )
619658
620659 finally :
621660 async with aiosqlite_engine .begin () as conn :
@@ -657,8 +696,12 @@ async def test_cache_manager_async_entity_methods_with_bind_group(
657696 await memory_cache_manager .set_entity_async (table_name , author_id , author , bind_group = "shard_a" )
658697
659698 # Verify both cached correctly
660- cached_default = await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = None )
661- cached_shard_a = await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
699+ cached_default = await memory_cache_manager .get_entity_async (
700+ table_name , author_id , BindGroupAuthor , bind_group = None
701+ )
702+ cached_shard_a = await memory_cache_manager .get_entity_async (
703+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
704+ )
662705
663706 assert cached_default is not None
664707 assert cached_shard_a is not None
@@ -669,8 +712,16 @@ async def test_cache_manager_async_entity_methods_with_bind_group(
669712 await memory_cache_manager .invalidate_entity_async (table_name , author_id , bind_group = "shard_a" )
670713
671714 # Verify only shard_a was invalidated
672- assert await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = None ) is not None
673- assert await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" ) is None
715+ assert (
716+ await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = None )
717+ is not None
718+ )
719+ assert (
720+ await memory_cache_manager .get_entity_async (
721+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
722+ )
723+ is None
724+ )
674725
675726 finally :
676727 async with aiosqlite_engine .begin () as conn :
@@ -725,9 +776,18 @@ async def test_cache_invalidation_tracker_commit_with_bind_group(
725776 tracker .commit ()
726777
727778 # Verify only shard_a was invalidated
728- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None ) is not None
729- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" ) is None
730- assert memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_b" ) is not None
779+ assert (
780+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = None )
781+ is not None
782+ )
783+ assert (
784+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" )
785+ is None
786+ )
787+ assert (
788+ memory_cache_manager .get_entity_sync (table_name , author_id , BindGroupAuthor , bind_group = "shard_b" )
789+ is not None
790+ )
731791
732792 finally :
733793 async with aiosqlite_engine .begin () as conn :
@@ -776,8 +836,16 @@ async def test_cache_invalidation_tracker_async_commit_with_bind_group(
776836 await tracker .commit_async ()
777837
778838 # Verify only shard_a was invalidated
779- assert await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = None ) is not None
780- assert await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = "shard_a" ) is None
839+ assert (
840+ await memory_cache_manager .get_entity_async (table_name , author_id , BindGroupAuthor , bind_group = None )
841+ is not None
842+ )
843+ assert (
844+ await memory_cache_manager .get_entity_async (
845+ table_name , author_id , BindGroupAuthor , bind_group = "shard_a"
846+ )
847+ is None
848+ )
781849
782850 finally :
783851 async with aiosqlite_engine .begin () as conn :
0 commit comments