Building AI agents, atomically
fixing flake and black formatting on file
jon fox9e809700d9e8
diff --git a/atomic-forge/tools/webpage_scraper/tests/test_webpage_scraper.py b/atomic-forge/tools/webpage_scraper/tests/test_webpage_scraper.pyindex 6834b86..bfc829a 100644--- a/atomic-forge/tools/webpage_scraper/tests/test_webpage_scraper.py+++ b/atomic-forge/tools/webpage_scraper/tests/test_webpage_scraper.py@@ -2,7 +2,6 @@ import osimport sysimport pytestfrom unittest.mock import patch, MagicMock-from urllib.parse import urlparsesys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))@@ -11,7 +10,6 @@ from tool.webpage_scraper import ( # noqa: E402WebpageScraperToolInputSchema,WebpageScraperToolOutputSchema,WebpageScraperToolConfig,- WebpageMetadata,)@@ -39,7 +37,7 @@ def mock_requests_get():mock_response.content = mock_response.text.encode("utf-8")mock_response.status_code = 200mock_response.raise_for_status = MagicMock()-+# Configure the mockmock_get.return_value = mock_responseyield mock_get@@ -49,10 +47,10 @@ def test_webpage_scraper_tool_basic(mock_requests_get):# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig())input_schema = WebpageScraperToolInputSchema(url="https://example.com")-+# Run the toolresult = scraper_tool.run(input_schema)-+# Assertionsassert isinstance(result, WebpageScraperToolOutputSchema)assert "Test Heading" in result.content@@ -70,10 +68,10 @@ def test_webpage_scraper_tool_without_links(mock_requests_get):# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig())input_schema = WebpageScraperToolInputSchema(url="https://example.com", include_links=False)-+# Run the toolresult = scraper_tool.run(input_schema)-+# Assertionsassert isinstance(result, WebpageScraperToolOutputSchema)assert "Test paragraph with link" in result.content@@ -83,14 +81,14 @@ def test_webpage_scraper_tool_without_links(mock_requests_get):def test_webpage_scraper_tool_http_error(mock_requests_get):# Configure mock to raise an exceptionmock_requests_get.return_value.raise_for_status.side_effect = Exception("404 Client Error")-+# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig())input_schema = WebpageScraperToolInputSchema(url="https://example.com/not-found")-+# Run the toolresult = scraper_tool.run(input_schema)-+# Assertionsassert isinstance(result, WebpageScraperToolOutputSchema)assert result.content == "" # Content should be empty@@ -103,14 +101,14 @@ def test_webpage_scraper_tool_content_too_large(mock_requests_get):# Configure mock content to exceed max lengthmax_length = 1_000_000mock_requests_get.return_value.content = b"a" * (max_length + 1)-+# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig(max_content_length=max_length))input_schema = WebpageScraperToolInputSchema(url="https://example.com/large-page")-+# Run the toolresult = scraper_tool.run(input_schema)-+# Assertionsassert isinstance(result, WebpageScraperToolOutputSchema)assert "exceeds maximum" in result.error@@ -119,20 +117,20 @@ def test_webpage_scraper_tool_content_too_large(mock_requests_get):def test_webpage_scraper_tool_extract_metadata():# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig())-+# Create a minimal soup object with metadatasoup = MagicMock()-+# Create individual mock tags with get methodsauthor_tag = MagicMock()author_tag.get.return_value = "Author Name"-+description_tag = MagicMock()description_tag.get.return_value = "Page Description"-+site_name_tag = MagicMock()site_name_tag.get.return_value = "Site Name"-+# Configure find method to return the right mock based on argumentsdef mock_find(tag, attrs=None):if tag == "meta" and attrs == {"name": "author"}:@@ -142,15 +140,15 @@ def test_webpage_scraper_tool_extract_metadata():elif tag == "meta" and attrs == {"property": "og:site_name"}:return site_name_tagreturn None-+soup.find.side_effect = mock_find-+doc = MagicMock()doc.title.return_value = "Page Title"-+# Call the method directlymetadata = scraper_tool._extract_metadata(soup, doc, "https://example.org/page")-+# Assertionsassert metadata.title == "Page Title"assert metadata.author == "Author Name"@@ -162,25 +160,24 @@ def test_webpage_scraper_tool_extract_metadata():def test_webpage_scraper_tool_clean_markdown():# Initialize the toolscraper_tool = WebpageScraperTool(WebpageScraperToolConfig())-+# Input markdown with excess whitespacedirty_markdown = """# Title---- Paragraph with trailing spaces--- * List item 1++++ Paragraph with trailing spaces++ * List item 1* List item 2--++"""-+# Clean the markdowncleaned = scraper_tool._clean_markdown(dirty_markdown)-+# Assertionsassert cleaned.count("\n\n\n") == 0 # No triple newlinesassert "spaces \n" not in cleaned # No trailing spaces@@ -188,4 +185,4 @@ def test_webpage_scraper_tool_clean_markdown():if __name__ == "__main__":- pytest.main([__file__])\ No newline at end of file+ pytest.main([__file__])