@@ -1594,14 +1594,14 @@ def test_process_knowledge_search_content_with_valid_metadata(mocker):
15941594Content: Test content
15951595Metadata: {'docs_url': 'https://example.com/doc1', 'title': 'Test Doc', 'document_id': 'doc-1'}
15961596"""
1597-
1597+
15981598 tool_response = mocker .Mock ()
15991599 tool_response .content = [text_content_item ]
1600-
1600+
16011601 metadata_map = {}
1602-
1602+
16031603 _process_knowledge_search_content (tool_response , metadata_map )
1604-
1604+
16051605 # Verify metadata was correctly parsed and added
16061606 assert "doc-1" in metadata_map
16071607 assert metadata_map ["doc-1" ]["docs_url" ] == "https://example.com/doc1"
@@ -1612,24 +1612,24 @@ def test_process_knowledge_search_content_with_valid_metadata(mocker):
16121612def test_process_knowledge_search_content_with_invalid_metadata_syntax_error (mocker ):
16131613 """Test _process_knowledge_search_content handles SyntaxError from invalid metadata."""
16141614 mock_logger = mocker .patch ("app.endpoints.query.logger" )
1615-
1615+
16161616 # Mock tool response with invalid metadata (invalid Python syntax)
16171617 text_content_item = mocker .Mock ()
16181618 text_content_item .text = """Result 1
16191619Content: Test content
16201620Metadata: {'docs_url': 'https://example.com/doc1' 'title': 'Test Doc', 'document_id': 'doc-1'}
16211621""" # Missing comma between 'doc1' and 'title' - will cause SyntaxError
1622-
1622+
16231623 tool_response = mocker .Mock ()
16241624 tool_response .content = [text_content_item ]
1625-
1625+
16261626 metadata_map = {}
1627-
1627+
16281628 _process_knowledge_search_content (tool_response , metadata_map )
1629-
1629+
16301630 # Verify metadata_map remains empty due to exception
16311631 assert len (metadata_map ) == 0
1632-
1632+
16331633 # Verify debug logging was called
16341634 mock_logger .debug .assert_called_once ()
16351635 args = mock_logger .debug .call_args [0 ]
@@ -1639,24 +1639,24 @@ def test_process_knowledge_search_content_with_invalid_metadata_syntax_error(moc
16391639def test_process_knowledge_search_content_with_invalid_metadata_value_error (mocker ):
16401640 """Test _process_knowledge_search_content handles ValueError from invalid metadata."""
16411641 mock_logger = mocker .patch ("app.endpoints.query.logger" )
1642-
1642+
16431643 # Mock tool response with invalid metadata containing complex expressions
16441644 text_content_item = mocker .Mock ()
16451645 text_content_item .text = """Result 1
16461646Content: Test content
16471647Metadata: {func_call(): 'value', 'title': 'Test Doc', 'document_id': 'doc-1'}
16481648""" # Function call in dict - will cause ValueError since it's not a literal
1649-
1649+
16501650 tool_response = mocker .Mock ()
16511651 tool_response .content = [text_content_item ]
1652-
1652+
16531653 metadata_map = {}
1654-
1654+
16551655 _process_knowledge_search_content (tool_response , metadata_map )
1656-
1656+
16571657 # Verify metadata_map remains empty due to exception
16581658 assert len (metadata_map ) == 0
1659-
1659+
16601660 # Verify debug logging was called
16611661 mock_logger .debug .assert_called_once ()
16621662 args = mock_logger .debug .call_args [0 ]
@@ -1666,24 +1666,24 @@ def test_process_knowledge_search_content_with_invalid_metadata_value_error(mock
16661666def test_process_knowledge_search_content_with_non_dict_metadata (mocker ):
16671667 """Test _process_knowledge_search_content handles non-dict metadata gracefully."""
16681668 mock_logger = mocker .patch ("app.endpoints.query.logger" )
1669-
1669+
16701670 # Mock tool response with metadata that's not a dict
16711671 text_content_item = mocker .Mock ()
16721672 text_content_item .text = """Result 1
16731673Content: Test content
16741674Metadata: "just a string"
16751675"""
1676-
1676+
16771677 tool_response = mocker .Mock ()
16781678 tool_response .content = [text_content_item ]
1679-
1679+
16801680 metadata_map = {}
1681-
1681+
16821682 _process_knowledge_search_content (tool_response , metadata_map )
1683-
1683+
16841684 # Verify metadata_map remains empty (no document_id in string)
16851685 assert len (metadata_map ) == 0
1686-
1686+
16871687 # No exception should be logged since string is valid literal
16881688 mock_logger .debug .assert_not_called ()
16891689
@@ -1696,14 +1696,14 @@ def test_process_knowledge_search_content_with_metadata_missing_document_id(mock
16961696Content: Test content
16971697Metadata: {'docs_url': 'https://example.com/doc1', 'title': 'Test Doc'}
16981698""" # No document_id field
1699-
1699+
17001700 tool_response = mocker .Mock ()
17011701 tool_response .content = [text_content_item ]
1702-
1702+
17031703 metadata_map = {}
1704-
1704+
17051705 _process_knowledge_search_content (tool_response , metadata_map )
1706-
1706+
17071707 # Verify metadata_map remains empty since document_id is missing
17081708 assert len (metadata_map ) == 0
17091709
@@ -1712,13 +1712,13 @@ def test_process_knowledge_search_content_with_no_text_attribute(mocker):
17121712 """Test _process_knowledge_search_content skips content items without text attribute."""
17131713 # Mock tool response with content item that has no text attribute
17141714 text_content_item = mocker .Mock (spec = []) # spec=[] means no attributes
1715-
1715+
17161716 tool_response = mocker .Mock ()
17171717 tool_response .content = [text_content_item ]
1718-
1718+
17191719 metadata_map = {}
1720-
1720+
17211721 _process_knowledge_search_content (tool_response , metadata_map )
1722-
1722+
17231723 # Verify metadata_map remains empty since text attribute is missing
17241724 assert len (metadata_map ) == 0
0 commit comments