@@ -98,7 +98,7 @@ def postgres_cache_config() -> PostgreSQLDatabaseConfiguration:
9898 port, db, user, and a SecretStr password. Values are placeholders and
9999 not intended for real database connections.
100100 """
101- # can be any configuration, becuase tests won't really try to
101+ # can be any configuration, because tests won't really try to
102102 # connect to database
103103 return PostgreSQLDatabaseConfiguration (
104104 host = "localhost" ,
@@ -122,7 +122,7 @@ def postgres_cache_config_wrong_namespace() -> PostgreSQLDatabaseConfiguration:
122122 spaces. Values are placeholders and not intended for real database
123123 connections.
124124 """
125- # can be any configuration, becuase tests won't really try to
125+ # can be any configuration, because tests won't really try to
126126 # connect to database
127127 return PostgreSQLDatabaseConfiguration (
128128 host = "localhost" ,
@@ -147,7 +147,7 @@ def postgres_cache_config_too_long_namespace() -> PostgreSQLDatabaseConfiguratio
147147 characters. Values are placeholders and not intended for real database
148148 connections.
149149 """
150- # can be any configuration, becuase tests won't really try to
150+ # can be any configuration, because tests won't really try to
151151 # connect to database
152152 return PostgreSQLDatabaseConfiguration (
153153 host = "localhost" ,
@@ -183,7 +183,14 @@ def test_cache_initialization_on_error(
183183 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
184184 mocker : MockerFixture ,
185185) -> None :
186- """Test the get operation when DB is not connected."""
186+ """Test the get operation when DB is not connected.
187+
188+ Asserts that constructing PostgresCache propagates an exception raised
189+ while establishing the database connection.
190+
191+ This test patches the PostgreSQL connector to raise Exception("foo") and
192+ verifies that PostgresCache(...) raises the same exception.
193+ """
187194 # prevent real connection to PG instance
188195 mocker .patch ("psycopg2.connect" , side_effect = Exception ("foo" ))
189196
@@ -265,7 +272,14 @@ def test_initialize_cache_when_connected(
265272 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
266273 mocker : MockerFixture ,
267274) -> None :
268- """Test the initialize_cache()."""
275+ """Test the initialize_cache().
276+
277+ Ensure initialize_cache completes without error when a database connection is available.
278+
279+ Uses a mocked psycopg2.connect to simulate connectivity, constructs a
280+ PostgresCache with the provided configuration, and asserts that calling
281+ initialize_cache("public") does not raise an exception.
282+ """
269283 # prevent real connection to PG instance
270284 mocker .patch ("psycopg2.connect" )
271285 cache = PostgresCache (postgres_cache_config_fixture )
@@ -291,7 +305,13 @@ def test_ready_method(
291305 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
292306 mocker : MockerFixture ,
293307) -> None :
294- """Test the ready() method."""
308+ """Test the ready() method.
309+
310+ Verify that PostgresCache.ready() returns True when the cache has an active connection.
311+
312+ Patches psycopg2.connect to avoid a real database and constructs a
313+ PostgresCache; calling ready() must return True.
314+ """
295315 # prevent real connection to PG instance
296316 mocker .patch ("psycopg2.connect" )
297317 cache = PostgresCache (postgres_cache_config_fixture )
@@ -326,7 +346,15 @@ def test_get_operation_when_connected(
326346 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
327347 mocker : MockerFixture ,
328348) -> None :
329- """Test the get() method."""
349+ """Test the get() method.
350+
351+ Verify that calling get() on a connected PostgresCache does not raise and
352+ yields no entries for the given user and conversation.
353+
354+ The test patches psycopg2.connect to avoid a real database connection,
355+ constructs a PostgresCache using the provided fixture, calls get() with
356+ USER_ID_1 and CONVERSATION_ID_1, and asserts the returned list is empty.
357+ """
330358 # prevent real connection to PG instance
331359 mocker .patch ("psycopg2.connect" )
332360 cache = PostgresCache (postgres_cache_config_fixture )
@@ -337,11 +365,23 @@ def test_get_operation_when_connected(
337365
338366
339367def test_get_operation_returned_values () -> None :
340- """Test the get() method."""
368+ """Test the get() method.
369+
370+ Verify that PostgresCache.get() reconstructs and returns CacheEntry objects
371+ from database rows.
372+
373+ This test should mock the database cursor to return rows representing
374+ stored cache entries (including JSON columns for referenced_documents,
375+ tool_calls, and tool_results) and assert that get(...) returns a list of
376+ CacheEntry instances whose fields match the original inserted data. The
377+ mock should emulate cursor.execute()/fetchall() behavior for realistic
378+ values and cover cases with and without optional JSON fields.
379+ """
341380 # TODO: LCORE-721
342381 # TODO: Implement proper unit test for testing PostgreSQL cache 'get' operation
343382 # returning 'real' values
344383 # Need to mock the cursor.execute() method
384+ pytest .skip ("Not yet implemented - see LCORE-721" )
345385
346386
347387def test_insert_or_append_when_disconnected (
@@ -412,7 +452,15 @@ def test_delete_operation_when_connected(
412452 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
413453 mocker : MockerFixture ,
414454) -> None :
415- """Test the delete() method."""
455+ """Test the delete() method.
456+
457+ Verifies that delete() returns True when a database deletion affects one
458+ row and False when it affects zero rows.
459+
460+ The test uses a mocked database cursor to simulate `rowcount = 1` and
461+ `rowcount = 0` and asserts the corresponding boolean return values from
462+ `PostgresCache.delete`.
463+ """
416464 # prevent real connection to PG instance
417465 mock_connect = mocker .patch ("psycopg2.connect" )
418466 cache = PostgresCache (postgres_cache_config_fixture )
@@ -457,7 +505,13 @@ def test_list_operation_when_disconnected(
457505 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
458506 mocker : MockerFixture ,
459507) -> None :
460- """Test the list() method."""
508+ """Test the list() method.
509+
510+ Verifies that calling list on a PostgresCache with no active connection raises a CacheError.
511+
512+ Asserts that when the cache's connection is None (and connect is a no-op),
513+ invoking list(...) raises CacheError with message "cache is disconnected".
514+ """
461515 # prevent real connection to PG instance
462516 mocker .patch ("psycopg2.connect" )
463517 cache = PostgresCache (postgres_cache_config_fixture )
@@ -543,6 +597,11 @@ def test_topic_summary_after_conversation_delete(
543597 deleted = cache .delete (USER_ID_1 , CONVERSATION_ID_1 , False )
544598 assert deleted is True
545599
600+ # Verify topic summary is no longer returned
601+ mock_cursor .fetchall .return_value = [] # Should be empty after deletion
602+ conversations = cache .list (USER_ID_1 , False )
603+ assert len (conversations ) == 0
604+
546605
547606def test_topic_summary_when_disconnected (
548607 postgres_cache_config_fixture : PostgreSQLDatabaseConfiguration ,
0 commit comments