Skip to content

Commit 98bf72d

Browse files
committed
Codestyle changes
1 parent 30717aa commit 98bf72d

File tree

1 file changed

+105
-53
lines changed

1 file changed

+105
-53
lines changed

tests/test_cache.py

Lines changed: 105 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,10 @@ def test_set_non_existing_cache_key(self, cache_key, mock_connection):
816816

817817
assert cache.set(
818818
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,
821823
)
822824
)
823825
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):
830832

831833
assert cache.set(
832834
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,
835839
)
836840
)
837841
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):
854858

855859
assert not cache.set(
856860
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,
859865
)
860866
)
861867

@@ -868,20 +874,26 @@ def test_set_evict_lru_cache_key_on_reaching_max_size(self, mock_connection):
868874
# Set 3 different keys
869875
assert cache.set(
870876
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,
873881
)
874882
)
875883
assert cache.set(
876884
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,
879889
)
880890
)
881891
assert cache.set(
882892
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,
885897
)
886898
)
887899

@@ -894,8 +906,10 @@ def test_set_evict_lru_cache_key_on_reaching_max_size(self, mock_connection):
894906
cache_key4 = CacheKey(command="GET", redis_keys=("foo3",))
895907
assert cache.set(
896908
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,
899913
)
900914
)
901915

@@ -911,8 +925,10 @@ def test_get_return_correct_value(self, cache_key, mock_connection):
911925

912926
assert cache.set(
913927
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,
916932
)
917933
)
918934
assert cache.get(cache_key).cache_value == b"val"
@@ -926,7 +942,7 @@ def test_get_return_correct_value(self, cache_key, mock_connection):
926942
cache_key=cache_key,
927943
cache_value=b"new_val",
928944
status=CacheEntryStatus.VALID,
929-
connection_ref=mock_connection
945+
connection_ref=mock_connection,
930946
)
931947
)
932948

@@ -944,20 +960,26 @@ def test_delete_by_cache_keys_removes_associated_entries(self, mock_connection):
944960
# Set 3 different keys
945961
assert cache.set(
946962
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,
949967
)
950968
)
951969
assert cache.set(
952970
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,
955975
)
956976
)
957977
assert cache.set(
958978
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,
961983
)
962984
)
963985

@@ -980,26 +1002,34 @@ def test_delete_by_redis_keys_removes_associated_entries(self, mock_connection):
9801002
# Set 3 different keys
9811003
assert cache.set(
9821004
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,
9851009
)
9861010
)
9871011
assert cache.set(
9881012
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,
9911017
)
9921018
)
9931019
assert cache.set(
9941020
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,
9971025
)
9981026
)
9991027
assert cache.set(
10001028
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,
10031033
)
10041034
)
10051035

@@ -1017,20 +1047,26 @@ def test_flush(self, mock_connection):
10171047
# Set 3 different keys
10181048
assert cache.set(
10191049
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,
10221054
)
10231055
)
10241056
assert cache.set(
10251057
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,
10281062
)
10291063
)
10301064
assert cache.set(
10311065
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,
10341070
)
10351071
)
10361072

@@ -1054,14 +1090,18 @@ def test_evict_next(self, mock_connection):
10541090

10551091
assert cache.set(
10561092
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,
10591097
)
10601098
)
10611099
assert cache.set(
10621100
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,
10651105
)
10661106
)
10671107

@@ -1079,20 +1119,26 @@ def test_evict_many(self, mock_connection):
10791119

10801120
assert cache.set(
10811121
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,
10841126
)
10851127
)
10861128
assert cache.set(
10871129
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,
10901134
)
10911135
)
10921136
assert cache.set(
10931137
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,
10961142
)
10971143
)
10981144

@@ -1114,22 +1160,28 @@ def test_touch(self, mock_connection):
11141160

11151161
cache.set(
11161162
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,
11191167
)
11201168
)
11211169
cache.set(
11221170
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,
11251175
)
11261176
)
11271177

11281178
assert cache.get_collection().popitem(last=True)[0] == cache_key2
11291179
cache.set(
11301180
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,
11331185
)
11341186
)
11351187

0 commit comments

Comments
 (0)