Skip to content

Commit c935951

Browse files
committed
Cleanup tests
1 parent 5c71fa7 commit c935951

File tree

1 file changed

+33
-9
lines changed
  • libs/langgraph-checkpoint-aws/tests/unit_tests/agentcore

1 file changed

+33
-9
lines changed

libs/langgraph-checkpoint-aws/tests/unit_tests/agentcore/test_saver.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
OVERHEAD_RUNNER_TIME = 0.05
4242
TOTAL_EXPECTED_TIME = MOCK_SLEEP_DURATION + OVERHEAD_RUNNER_TIME
4343

44+
4445
@pytest.fixture
4546
def sample_checkpoint_tuple():
4647
"""Helper to create a mock checkpoint tuple with configurable IDs."""
@@ -60,9 +61,6 @@ def sample_checkpoint_tuple():
6061
)
6162

6263

63-
64-
65-
6664
@pytest.fixture
6765
def sample_checkpoint_event():
6866
return CheckpointEvent(
@@ -176,45 +174,55 @@ def sample_checkpoint_metadata(self):
176174
"namespace2": "parent_checkpoint_2",
177175
},
178176
)
179-
177+
180178
@pytest.fixture
181179
def slow_get_tuple(self, sample_checkpoint_tuple):
182180
"""Mock get_tuple with artificial delay for testing async concurrency."""
181+
183182
def _slow_get_tuple(config): # noqa: ARG001
184183
time.sleep(MOCK_SLEEP_DURATION)
185184
return sample_checkpoint_tuple
185+
186186
return _slow_get_tuple
187187

188188
@pytest.fixture
189189
def slow_list(self, sample_checkpoint_tuple):
190190
"""Mock list with artificial delay for testing async concurrency."""
191+
191192
def _slow_list(config, *, filter=None, before=None, limit=None): # noqa: ARG001 A002
192193
time.sleep(MOCK_SLEEP_DURATION)
193194
return [sample_checkpoint_tuple]
195+
194196
return _slow_list
195197

196198
@pytest.fixture
197199
def slow_put(self):
198200
"""Mock put with artificial delay for testing async concurrency."""
201+
199202
def _slow_put(config, checkpoint, metadata, new_versions): # noqa: ARG001
200203
time.sleep(MOCK_SLEEP_DURATION)
201204
return config
205+
202206
return _slow_put
203207

204208
@pytest.fixture
205209
def slow_put_writes(self):
206210
"""Mock put_writes with artificial delay for testing async concurrency."""
211+
207212
def _slow_put_writes(config, writes, task_id, task_path=""): # noqa: ARG001
208213
time.sleep(MOCK_SLEEP_DURATION)
209214
return
215+
210216
return _slow_put_writes
211217

212218
@pytest.fixture
213219
def slow_delete_thread(self):
214220
"""Mock delete_thread with artificial delay for testing async concurrency."""
221+
215222
def _slow_delete_thread(thread_id, actor_id=""): # noqa: ARG001
216223
time.sleep(MOCK_SLEEP_DURATION)
217224
return
225+
218226
return _slow_delete_thread
219227

220228
def test_init_with_default_client(self, memory_id):
@@ -705,7 +713,12 @@ async def test_alist_calls_sync_method_with_correct_args(
705713
assert isinstance(items[0], CheckpointTuple)
706714

707715
async def test_aput_calls_sync_method_with_correct_args(
708-
self, saver, runnable_config, sample_checkpoint, sample_checkpoint_metadata, slow_put
716+
self,
717+
saver,
718+
runnable_config,
719+
sample_checkpoint,
720+
sample_checkpoint_metadata,
721+
slow_put,
709722
):
710723
"""Test that aput calls the sync put method with correct arguments."""
711724

@@ -773,14 +786,18 @@ async def test_adelete_thread_calls_sync_method_with_correct_args(
773786
mock_delete.assert_called_once_with(thread_id, actor_id)
774787
assert result is None
775788

776-
async def test_concurrent_calls_aget_tuple(self, saver, runnable_config, slow_get_tuple):
789+
async def test_concurrent_calls_aget_tuple(
790+
self, saver, runnable_config, slow_get_tuple
791+
):
777792
"""Test that concurrent calls are faster than sequential calls."""
778793
with patch.object(saver, "get_tuple", side_effect=slow_get_tuple):
779794
await self.assert_concurrent_calls_are_faster_than_sequential(
780795
N_ASYNC_CALLS, saver.aget_tuple, runnable_config
781796
)
782797

783-
async def test_concurrent_calls_adelete_thread(self, saver, runnable_config, slow_delete_thread):
798+
async def test_concurrent_calls_adelete_thread(
799+
self, saver, runnable_config, slow_delete_thread
800+
):
784801
"""Test that concurrent calls are faster than sequential calls."""
785802
thread_id = runnable_config["configurable"]["thread_id"]
786803
actor_id = runnable_config["configurable"]["actor_id"]
@@ -790,7 +807,9 @@ async def test_concurrent_calls_adelete_thread(self, saver, runnable_config, slo
790807
N_ASYNC_CALLS, saver.adelete_thread, thread_id, actor_id
791808
)
792809

793-
async def test_concurrent_calls_aput_writes(self, saver, runnable_config, slow_put_writes):
810+
async def test_concurrent_calls_aput_writes(
811+
self, saver, runnable_config, slow_put_writes
812+
):
794813
"""Test that concurrent calls are faster than sequential calls."""
795814
writes = [("channel", "value")]
796815
task_id = "test-task"
@@ -807,7 +826,12 @@ async def test_concurrent_calls_aput_writes(self, saver, runnable_config, slow_p
807826
)
808827

809828
async def test_concurrent_calls_aput(
810-
self, saver, runnable_config, sample_checkpoint, sample_checkpoint_metadata, slow_put
829+
self,
830+
saver,
831+
runnable_config,
832+
sample_checkpoint,
833+
sample_checkpoint_metadata,
834+
slow_put,
811835
):
812836
"""Test that concurrent calls are faster than sequential calls."""
813837
new_versions = {"default": "v2"}

0 commit comments

Comments
 (0)