@@ -534,6 +534,29 @@ def test_get_updates_after_delete(self, cache: PartitionTransactionCache):
534
534
cache .delete (key = b"key" , prefix = b"prefix" , cf_name = "cf_name" )
535
535
assert cache .get_updates (cf_name = "cf_name" ) == {b"prefix" : {}}
536
536
537
+ def test_get_updates_for_prefix_empty (self , cache : PartitionTransactionCache ):
538
+ assert cache .get_updates_for_prefix (prefix = b"prefix" , cf_name = "cf_name" ) == {}
539
+
540
+ # Delete an item and make sure it's not in "updates"
541
+ cache .delete (key = b"key" , prefix = b"prefix" , cf_name = "cf_name" )
542
+ assert cache .get_updates_for_prefix (prefix = b"prefix" , cf_name = "cf_name" ) == {}
543
+
544
+ def test_get_updates_for_prefix_present (self , cache : PartitionTransactionCache ):
545
+ cache .set (key = b"key" , value = b"value" , prefix = b"prefix" , cf_name = "cf_name" )
546
+ cache .set (key = b"key" , value = b"value" , prefix = b"other_prefix" , cf_name = "cf_name" )
547
+ cache .set (key = b"key" , value = b"value" , prefix = b"other" , cf_name = "other_cf_name" )
548
+
549
+ assert cache .get_updates_for_prefix (prefix = b"prefix" , cf_name = "cf_name" ) == {
550
+ b"key" : b"value"
551
+ }
552
+
553
+ def test_get_updates_for_prefix_after_delete (
554
+ self , cache : PartitionTransactionCache
555
+ ):
556
+ cache .set (key = b"key" , value = b"value" , prefix = b"prefix" , cf_name = "cf_name" )
557
+ cache .delete (key = b"key" , prefix = b"prefix" , cf_name = "cf_name" )
558
+ assert cache .get_updates_for_prefix (prefix = b"prefix" , cf_name = "cf_name" ) == {}
559
+
537
560
def test_get_deletes_empty (self , cache : PartitionTransactionCache ):
538
561
assert cache .get_deletes (cf_name = "cf_name" ) == set ()
539
562
@@ -567,25 +590,3 @@ def test_get_deletes_after_set(self, cache: PartitionTransactionCache):
567
590
def test_empty (self , action , expected , cache ):
568
591
action (cache )
569
592
assert cache .is_empty () == expected
570
-
571
- def test_iter_items (self , cache : PartitionTransactionCache ):
572
- cache .set (key = b"key1" , value = b"value1" , prefix = b"prefix" )
573
- cache .set (key = b"key2" , value = b"value2" , prefix = b"prefix" )
574
- cache .set (key = b"key3" , value = b"value3" , prefix = b"prefix" )
575
- cache .set (key = b"key4" , value = b"value4" , prefix = b"prefix" , cf_name = "other" )
576
-
577
- assert cache .iter_items (prefix = b"prefix" ) == [
578
- (b"key1" , b"value1" ),
579
- (b"key2" , b"value2" ),
580
- (b"key3" , b"value3" ),
581
- ]
582
-
583
- assert cache .iter_items (prefix = b"prefix" , backwards = True ) == [
584
- (b"key3" , b"value3" ),
585
- (b"key2" , b"value2" ),
586
- (b"key1" , b"value1" ),
587
- ]
588
-
589
- assert cache .iter_items (prefix = b"prefix" , cf_name = "other" ) == [
590
- (b"key4" , b"value4" ),
591
- ]
0 commit comments