@@ -73,11 +73,13 @@ async def test_should_not_release_a_lock_with_wrong_token(
7373 lock = await adapter .acquire_lock ("thread1" , 5000 )
7474 assert lock is not None
7575
76- await adapter .release_lock ({
77- "thread_id" : "thread1" ,
78- "token" : "fake-token" ,
79- "expires_at" : 0 ,
80- })
76+ await adapter .release_lock (
77+ {
78+ "thread_id" : "thread1" ,
79+ "token" : "fake-token" ,
80+ "expires_at" : 0 ,
81+ }
82+ )
8183
8284 # Original lock should still be held
8385 lock2 = await adapter .acquire_lock ("thread1" , 5000 )
@@ -86,9 +88,7 @@ async def test_should_not_release_a_lock_with_wrong_token(
8688 # Clean up
8789 await adapter .release_lock (lock )
8890
89- async def test_should_allow_re_locking_after_expiry (
90- self , adapter : MemoryStateAdapter
91- ) -> None :
91+ async def test_should_allow_re_locking_after_expiry (self , adapter : MemoryStateAdapter ) -> None :
9292 lock1 = await adapter .acquire_lock ("thread1" , 10 ) # 10ms TTL
9393
9494 await asyncio .sleep (0.020 ) # 20ms
@@ -127,9 +127,7 @@ async def test_should_no_op_when_force_releasing_a_non_existent_lock(
127127 result = await adapter .force_release_lock ("nonexistent" )
128128 assert result is None
129129
130- async def test_should_not_extend_an_expired_lock (
131- self , adapter : MemoryStateAdapter
132- ) -> None :
130+ async def test_should_not_extend_an_expired_lock (self , adapter : MemoryStateAdapter ) -> None :
133131 lock = await adapter .acquire_lock ("thread1" , 10 )
134132 assert lock is not None
135133
@@ -152,26 +150,20 @@ async def test_should_set_a_value_when_key_does_not_exist(
152150 assert result is True
153151 assert await adapter .get ("key1" ) == "value1"
154152
155- async def test_should_not_overwrite_an_existing_key (
156- self , adapter : MemoryStateAdapter
157- ) -> None :
153+ async def test_should_not_overwrite_an_existing_key (self , adapter : MemoryStateAdapter ) -> None :
158154 await adapter .set_if_not_exists ("key1" , "first" )
159155 result = await adapter .set_if_not_exists ("key1" , "second" )
160156 assert result is False
161157 assert await adapter .get ("key1" ) == "first"
162158
163- async def test_should_allow_setting_after_ttl_expiry (
164- self , adapter : MemoryStateAdapter
165- ) -> None :
159+ async def test_should_allow_setting_after_ttl_expiry (self , adapter : MemoryStateAdapter ) -> None :
166160 await adapter .set_if_not_exists ("key1" , "first" , 10 )
167161 await asyncio .sleep (0.020 )
168162 result = await adapter .set_if_not_exists ("key1" , "second" )
169163 assert result is True
170164 assert await adapter .get ("key1" ) == "second"
171165
172- async def test_should_respect_ttl_on_the_new_value (
173- self , adapter : MemoryStateAdapter
174- ) -> None :
166+ async def test_should_respect_ttl_on_the_new_value (self , adapter : MemoryStateAdapter ) -> None :
175167 await adapter .set_if_not_exists ("key1" , "value" , 10 )
176168 await asyncio .sleep (0.020 )
177169 assert await adapter .get ("key1" ) is None
@@ -183,9 +175,7 @@ async def test_should_respect_ttl_on_the_new_value(
183175
184176
185177class TestAppendToListGetList :
186- async def test_should_append_and_retrieve_list_items (
187- self , adapter : MemoryStateAdapter
188- ) -> None :
178+ async def test_should_append_and_retrieve_list_items (self , adapter : MemoryStateAdapter ) -> None :
189179 await adapter .append_to_list ("list1" , {"id" : 1 })
190180 await adapter .append_to_list ("list1" , {"id" : 2 })
191181
@@ -228,18 +218,14 @@ async def test_should_refresh_ttl_on_subsequent_appends(
228218 result = await adapter .get_list ("list1" )
229219 assert result == [{"id" : 1 }, {"id" : 2 }]
230220
231- async def test_should_keep_lists_isolated_by_key (
232- self , adapter : MemoryStateAdapter
233- ) -> None :
221+ async def test_should_keep_lists_isolated_by_key (self , adapter : MemoryStateAdapter ) -> None :
234222 await adapter .append_to_list ("list-a" , "a" )
235223 await adapter .append_to_list ("list-b" , "b" )
236224
237225 assert await adapter .get_list ("list-a" ) == ["a" ]
238226 assert await adapter .get_list ("list-b" ) == ["b" ]
239227
240- async def test_should_start_fresh_after_expired_list (
241- self , adapter : MemoryStateAdapter
242- ) -> None :
228+ async def test_should_start_fresh_after_expired_list (self , adapter : MemoryStateAdapter ) -> None :
243229 await adapter .append_to_list ("list1" , {"id" : 1 }, {"ttl_ms" : 10 })
244230 await asyncio .sleep (0.020 )
245231
@@ -353,9 +339,7 @@ async def test_should_handle_max_size_of_one_debounce_behavior(
353339 result = await adapter .dequeue ("thread1" )
354340 assert result ["message" ] == {"id" : "m3" }
355341
356- async def test_should_keep_queues_isolated_by_thread (
357- self , adapter : MemoryStateAdapter
358- ) -> None :
342+ async def test_should_keep_queues_isolated_by_thread (self , adapter : MemoryStateAdapter ) -> None :
359343 await adapter .enqueue (
360344 "thread-a" ,
361345 {"message" : {"id" : "a1" }, "enqueued_at" : 1000 , "expires_at" : 90000 },
@@ -376,9 +360,7 @@ async def test_should_keep_queues_isolated_by_thread(
376360 rb = await adapter .dequeue ("thread-b" )
377361 assert rb ["message" ] == {"id" : "b1" }
378362
379- async def test_should_clear_queues_on_disconnect (
380- self , adapter : MemoryStateAdapter
381- ) -> None :
363+ async def test_should_clear_queues_on_disconnect (self , adapter : MemoryStateAdapter ) -> None :
382364 await adapter .enqueue (
383365 "thread1" ,
384366 {"message" : {"id" : "m1" }, "enqueued_at" : 1000 , "expires_at" : 90000 },
@@ -403,9 +385,7 @@ async def test_should_throw_when_not_connected(self) -> None:
403385 with pytest .raises (RuntimeError , match = "not connected" ):
404386 await new_adapter .subscribe ("test" )
405387
406- async def test_should_clear_state_on_disconnect (
407- self , adapter : MemoryStateAdapter
408- ) -> None :
388+ async def test_should_clear_state_on_disconnect (self , adapter : MemoryStateAdapter ) -> None :
409389 await adapter .subscribe ("thread1" )
410390 await adapter .acquire_lock ("thread1" , 5000 )
411391
0 commit comments