Add webscraper MCP server (7 tools, httpx+bs4, 15+ tests)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Shared test fixtures for webscraper."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add src to path for imports
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
||||
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
@pytest.fixture
|
||||
def mock_httpx():
|
||||
"""Mock httpx for all network calls."""
|
||||
mock_get = MagicMock()
|
||||
mock_get.return_value.status_code = 200
|
||||
mock_get.return_value.text = "<html><body>Test</body></html>"
|
||||
mock_get.return_value.headers = {"content-type": "text/html"}
|
||||
|
||||
with MagicMock() as mock_module:
|
||||
mock_module.get.return_value = mock_get
|
||||
sys.modules["httpx"] = mock_module
|
||||
yield mock_module
|
||||
|
||||
@pytest.fixture
|
||||
def mock_bs4():
|
||||
"""Mock BeautifulSoup for parsing."""
|
||||
from bs4 import BeautifulSoup
|
||||
soup = BeautifulSoup("<html><body>Test</body></html>", "html.parser")
|
||||
return soup
|
||||
Reference in New Issue
Block a user