@@ -816,8 +816,10 @@ def test_set_non_existing_cache_key(self, cache_key, mock_connection):
816
816
817
817
assert cache .set (
818
818
CacheEntry (
819
- cache_key = cache_key , cache_value = b"val" , status = CacheEntryStatus .VALID ,
820
- connection_ref = mock_connection
819
+ cache_key = cache_key ,
820
+ cache_value = b"val" ,
821
+ status = CacheEntryStatus .VALID ,
822
+ connection_ref = mock_connection ,
821
823
)
822
824
)
823
825
assert cache .get (cache_key ).cache_value == b"val"
@@ -830,8 +832,10 @@ def test_set_updates_existing_cache_key(self, cache_key, mock_connection):
830
832
831
833
assert cache .set (
832
834
CacheEntry (
833
- cache_key = cache_key , cache_value = b"val" , status = CacheEntryStatus .VALID ,
834
- connection_ref = mock_connection
835
+ cache_key = cache_key ,
836
+ cache_value = b"val" ,
837
+ status = CacheEntryStatus .VALID ,
838
+ connection_ref = mock_connection ,
835
839
)
836
840
)
837
841
assert cache .get (cache_key ).cache_value == b"val"
@@ -854,8 +858,10 @@ def test_set_does_not_store_not_allowed_key(self, cache_key, mock_connection):
854
858
855
859
assert not cache .set (
856
860
CacheEntry (
857
- cache_key = cache_key , cache_value = b"val" , status = CacheEntryStatus .VALID ,
858
- connection_ref = mock_connection
861
+ cache_key = cache_key ,
862
+ cache_value = b"val" ,
863
+ status = CacheEntryStatus .VALID ,
864
+ connection_ref = mock_connection ,
859
865
)
860
866
)
861
867
@@ -868,20 +874,26 @@ def test_set_evict_lru_cache_key_on_reaching_max_size(self, mock_connection):
868
874
# Set 3 different keys
869
875
assert cache .set (
870
876
CacheEntry (
871
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
872
- connection_ref = mock_connection
877
+ cache_key = cache_key1 ,
878
+ cache_value = b"bar" ,
879
+ status = CacheEntryStatus .VALID ,
880
+ connection_ref = mock_connection ,
873
881
)
874
882
)
875
883
assert cache .set (
876
884
CacheEntry (
877
- cache_key = cache_key2 , cache_value = b"bar1" , status = CacheEntryStatus .VALID ,
878
- connection_ref = mock_connection
885
+ cache_key = cache_key2 ,
886
+ cache_value = b"bar1" ,
887
+ status = CacheEntryStatus .VALID ,
888
+ connection_ref = mock_connection ,
879
889
)
880
890
)
881
891
assert cache .set (
882
892
CacheEntry (
883
- cache_key = cache_key3 , cache_value = b"bar2" , status = CacheEntryStatus .VALID ,
884
- connection_ref = mock_connection
893
+ cache_key = cache_key3 ,
894
+ cache_value = b"bar2" ,
895
+ status = CacheEntryStatus .VALID ,
896
+ connection_ref = mock_connection ,
885
897
)
886
898
)
887
899
@@ -894,8 +906,10 @@ def test_set_evict_lru_cache_key_on_reaching_max_size(self, mock_connection):
894
906
cache_key4 = CacheKey (command = "GET" , redis_keys = ("foo3" ,))
895
907
assert cache .set (
896
908
CacheEntry (
897
- cache_key = cache_key4 , cache_value = b"bar3" , status = CacheEntryStatus .VALID ,
898
- connection_ref = mock_connection
909
+ cache_key = cache_key4 ,
910
+ cache_value = b"bar3" ,
911
+ status = CacheEntryStatus .VALID ,
912
+ connection_ref = mock_connection ,
899
913
)
900
914
)
901
915
@@ -911,8 +925,10 @@ def test_get_return_correct_value(self, cache_key, mock_connection):
911
925
912
926
assert cache .set (
913
927
CacheEntry (
914
- cache_key = cache_key , cache_value = b"val" , status = CacheEntryStatus .VALID ,
915
- connection_ref = mock_connection
928
+ cache_key = cache_key ,
929
+ cache_value = b"val" ,
930
+ status = CacheEntryStatus .VALID ,
931
+ connection_ref = mock_connection ,
916
932
)
917
933
)
918
934
assert cache .get (cache_key ).cache_value == b"val"
@@ -926,7 +942,7 @@ def test_get_return_correct_value(self, cache_key, mock_connection):
926
942
cache_key = cache_key ,
927
943
cache_value = b"new_val" ,
928
944
status = CacheEntryStatus .VALID ,
929
- connection_ref = mock_connection
945
+ connection_ref = mock_connection ,
930
946
)
931
947
)
932
948
@@ -944,20 +960,26 @@ def test_delete_by_cache_keys_removes_associated_entries(self, mock_connection):
944
960
# Set 3 different keys
945
961
assert cache .set (
946
962
CacheEntry (
947
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
948
- connection_ref = mock_connection
963
+ cache_key = cache_key1 ,
964
+ cache_value = b"bar" ,
965
+ status = CacheEntryStatus .VALID ,
966
+ connection_ref = mock_connection ,
949
967
)
950
968
)
951
969
assert cache .set (
952
970
CacheEntry (
953
- cache_key = cache_key2 , cache_value = b"bar1" , status = CacheEntryStatus .VALID ,
954
- connection_ref = mock_connection
971
+ cache_key = cache_key2 ,
972
+ cache_value = b"bar1" ,
973
+ status = CacheEntryStatus .VALID ,
974
+ connection_ref = mock_connection ,
955
975
)
956
976
)
957
977
assert cache .set (
958
978
CacheEntry (
959
- cache_key = cache_key3 , cache_value = b"bar2" , status = CacheEntryStatus .VALID ,
960
- connection_ref = mock_connection
979
+ cache_key = cache_key3 ,
980
+ cache_value = b"bar2" ,
981
+ status = CacheEntryStatus .VALID ,
982
+ connection_ref = mock_connection ,
961
983
)
962
984
)
963
985
@@ -980,26 +1002,34 @@ def test_delete_by_redis_keys_removes_associated_entries(self, mock_connection):
980
1002
# Set 3 different keys
981
1003
assert cache .set (
982
1004
CacheEntry (
983
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
984
- connection_ref = mock_connection
1005
+ cache_key = cache_key1 ,
1006
+ cache_value = b"bar" ,
1007
+ status = CacheEntryStatus .VALID ,
1008
+ connection_ref = mock_connection ,
985
1009
)
986
1010
)
987
1011
assert cache .set (
988
1012
CacheEntry (
989
- cache_key = cache_key2 , cache_value = b"bar1" , status = CacheEntryStatus .VALID ,
990
- connection_ref = mock_connection
1013
+ cache_key = cache_key2 ,
1014
+ cache_value = b"bar1" ,
1015
+ status = CacheEntryStatus .VALID ,
1016
+ connection_ref = mock_connection ,
991
1017
)
992
1018
)
993
1019
assert cache .set (
994
1020
CacheEntry (
995
- cache_key = cache_key3 , cache_value = b"bar2" , status = CacheEntryStatus .VALID ,
996
- connection_ref = mock_connection
1021
+ cache_key = cache_key3 ,
1022
+ cache_value = b"bar2" ,
1023
+ status = CacheEntryStatus .VALID ,
1024
+ connection_ref = mock_connection ,
997
1025
)
998
1026
)
999
1027
assert cache .set (
1000
1028
CacheEntry (
1001
- cache_key = cache_key4 , cache_value = b"bar3" , status = CacheEntryStatus .VALID ,
1002
- connection_ref = mock_connection
1029
+ cache_key = cache_key4 ,
1030
+ cache_value = b"bar3" ,
1031
+ status = CacheEntryStatus .VALID ,
1032
+ connection_ref = mock_connection ,
1003
1033
)
1004
1034
)
1005
1035
@@ -1017,20 +1047,26 @@ def test_flush(self, mock_connection):
1017
1047
# Set 3 different keys
1018
1048
assert cache .set (
1019
1049
CacheEntry (
1020
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
1021
- connection_ref = mock_connection
1050
+ cache_key = cache_key1 ,
1051
+ cache_value = b"bar" ,
1052
+ status = CacheEntryStatus .VALID ,
1053
+ connection_ref = mock_connection ,
1022
1054
)
1023
1055
)
1024
1056
assert cache .set (
1025
1057
CacheEntry (
1026
- cache_key = cache_key2 , cache_value = b"bar1" , status = CacheEntryStatus .VALID ,
1027
- connection_ref = mock_connection
1058
+ cache_key = cache_key2 ,
1059
+ cache_value = b"bar1" ,
1060
+ status = CacheEntryStatus .VALID ,
1061
+ connection_ref = mock_connection ,
1028
1062
)
1029
1063
)
1030
1064
assert cache .set (
1031
1065
CacheEntry (
1032
- cache_key = cache_key3 , cache_value = b"bar2" , status = CacheEntryStatus .VALID ,
1033
- connection_ref = mock_connection
1066
+ cache_key = cache_key3 ,
1067
+ cache_value = b"bar2" ,
1068
+ status = CacheEntryStatus .VALID ,
1069
+ connection_ref = mock_connection ,
1034
1070
)
1035
1071
)
1036
1072
@@ -1054,14 +1090,18 @@ def test_evict_next(self, mock_connection):
1054
1090
1055
1091
assert cache .set (
1056
1092
CacheEntry (
1057
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
1058
- connection_ref = mock_connection
1093
+ cache_key = cache_key1 ,
1094
+ cache_value = b"bar" ,
1095
+ status = CacheEntryStatus .VALID ,
1096
+ connection_ref = mock_connection ,
1059
1097
)
1060
1098
)
1061
1099
assert cache .set (
1062
1100
CacheEntry (
1063
- cache_key = cache_key2 , cache_value = b"foo" , status = CacheEntryStatus .VALID ,
1064
- connection_ref = mock_connection
1101
+ cache_key = cache_key2 ,
1102
+ cache_value = b"foo" ,
1103
+ status = CacheEntryStatus .VALID ,
1104
+ connection_ref = mock_connection ,
1065
1105
)
1066
1106
)
1067
1107
@@ -1079,20 +1119,26 @@ def test_evict_many(self, mock_connection):
1079
1119
1080
1120
assert cache .set (
1081
1121
CacheEntry (
1082
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
1083
- connection_ref = mock_connection
1122
+ cache_key = cache_key1 ,
1123
+ cache_value = b"bar" ,
1124
+ status = CacheEntryStatus .VALID ,
1125
+ connection_ref = mock_connection ,
1084
1126
)
1085
1127
)
1086
1128
assert cache .set (
1087
1129
CacheEntry (
1088
- cache_key = cache_key2 , cache_value = b"foo" , status = CacheEntryStatus .VALID ,
1089
- connection_ref = mock_connection
1130
+ cache_key = cache_key2 ,
1131
+ cache_value = b"foo" ,
1132
+ status = CacheEntryStatus .VALID ,
1133
+ connection_ref = mock_connection ,
1090
1134
)
1091
1135
)
1092
1136
assert cache .set (
1093
1137
CacheEntry (
1094
- cache_key = cache_key3 , cache_value = b"baz" , status = CacheEntryStatus .VALID ,
1095
- connection_ref = mock_connection
1138
+ cache_key = cache_key3 ,
1139
+ cache_value = b"baz" ,
1140
+ status = CacheEntryStatus .VALID ,
1141
+ connection_ref = mock_connection ,
1096
1142
)
1097
1143
)
1098
1144
@@ -1114,22 +1160,28 @@ def test_touch(self, mock_connection):
1114
1160
1115
1161
cache .set (
1116
1162
CacheEntry (
1117
- cache_key = cache_key1 , cache_value = b"bar" , status = CacheEntryStatus .VALID ,
1118
- connection_ref = mock_connection
1163
+ cache_key = cache_key1 ,
1164
+ cache_value = b"bar" ,
1165
+ status = CacheEntryStatus .VALID ,
1166
+ connection_ref = mock_connection ,
1119
1167
)
1120
1168
)
1121
1169
cache .set (
1122
1170
CacheEntry (
1123
- cache_key = cache_key2 , cache_value = b"foo" , status = CacheEntryStatus .VALID ,
1124
- connection_ref = mock_connection
1171
+ cache_key = cache_key2 ,
1172
+ cache_value = b"foo" ,
1173
+ status = CacheEntryStatus .VALID ,
1174
+ connection_ref = mock_connection ,
1125
1175
)
1126
1176
)
1127
1177
1128
1178
assert cache .get_collection ().popitem (last = True )[0 ] == cache_key2
1129
1179
cache .set (
1130
1180
CacheEntry (
1131
- cache_key = cache_key2 , cache_value = b"foo" , status = CacheEntryStatus .VALID ,
1132
- connection_ref = mock_connection
1181
+ cache_key = cache_key2 ,
1182
+ cache_value = b"foo" ,
1183
+ status = CacheEntryStatus .VALID ,
1184
+ connection_ref = mock_connection ,
1133
1185
)
1134
1186
)
1135
1187
0 commit comments