Test the SearchLinkNode execution.
(setup)
| 40 | |
| 41 | |
| 42 | def test_search_link_node(setup): |
| 43 | """ |
| 44 | Test the SearchLinkNode execution. |
| 45 | """ |
| 46 | search_link_node, initial_state = setup |
| 47 | |
| 48 | # Patch the execute method to avoid actual network calls and return a mock response |
| 49 | with patch.object( |
| 50 | SearchLinkNode, |
| 51 | "execute", |
| 52 | return_value={"relevant_links": ["http://example.com"]}, |
| 53 | ) as mock_execute: |
| 54 | result = search_link_node.execute(initial_state) |
| 55 | |
| 56 | # Check if the result is not None |
| 57 | assert result is not None |
| 58 | # Additional assertion to check the returned value |
| 59 | assert "relevant_links" in result |
| 60 | assert isinstance(result["relevant_links"], list) |
| 61 | assert len(result["relevant_links"]) > 0 |
| 62 | # Ensure the execute method was called once |
| 63 | mock_execute.assert_called_once_with(initial_state) |