Skip to main content
Glama
davinoishi

Broken Link Checker MCP Server

by davinoishi
test_link_validator.py1.85 kB
"""Tests for link validator.""" import pytest from src.link_validator import LinkValidator @pytest.mark.asyncio class TestLinkValidator: """Test the LinkValidator class.""" def setup_method(self): """Set up test fixtures.""" self.validator = LinkValidator(timeout=5.0) async def test_validate_good_link(self): """Test validation of a working link.""" # Use a reliable public URL status = await self.validator.validate_link("https://www.example.com") assert status == "Good" async def test_validate_bad_link(self): """Test validation of a broken link.""" # This should return 404 status = await self.validator.validate_link( "https://httpbin.org/status/404" ) assert status == "Bad" async def test_validate_timeout(self): """Test validation with timeout.""" # Use a URL that delays response validator = LinkValidator(timeout=1.0) status = await validator.validate_link( "https://httpbin.org/delay/5" ) assert status == "Bad" async def test_validate_invalid_url(self): """Test validation of invalid URL.""" status = await self.validator.validate_link("not-a-valid-url") assert status == "Bad" async def test_validate_multiple_links(self): """Test validation of multiple links concurrently.""" urls = [ "https://www.example.com", "https://httpbin.org/status/404", "https://www.google.com", ] results = await self.validator.validate_links(urls) assert len(results) == 3 assert results["https://www.example.com"] == "Good" assert results["https://httpbin.org/status/404"] == "Bad" assert results["https://www.google.com"] == "Good"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davinoishi/BLC-ground'

If you have feedback or need assistance with the MCP directory API, please join our Discord server