"""Tests for data loading functionality.""" import json from pathlib import Path from kg_services.ontology import MCPTool def test_initial_tools_json_structure(): """Test that initial_tools.json has valid structure.""" data_file = Path("data/initial_tools.json") assert data_file.exists(), "initial_tools.json should exist" with data_file.open() as f: tools_data = json.load(f) assert isinstance(tools_data, list), "JSON should contain a list of tools" assert len(tools_data) == 7, "Should have exactly 7 MCP tools for hackathon ecosystem" def test_initial_tools_create_mcp_tools(): """Test that JSON data can be used to create MCPTool instances.""" data_file = Path("data/initial_tools.json") with data_file.open() as f: tools_data = json.load(f) tools = [] for tool_data in tools_data: # Test that we can create MCPTool from JSON data tool = MCPTool(**tool_data) tools.append(tool) # Validate required fields assert tool.tool_id assert tool.name assert tool.description assert isinstance(tool.tags, list) assert isinstance(tool.invocation_command_stub, str) # Validate we have 7 tools for complete MCP ecosystem assert len(tools) == 7 # Check specific tools exist (hackathon MCP ecosystem) tool_ids = {tool.tool_id for tool in tools} expected_ids = { "text_summarizer_001", "sentiment_analyzer_002", "code_analyzer_005", "file_processor_006", "math_calculator_007", "web_scraper_008", "enhanced_image_009", } assert tool_ids == expected_ids def test_tool_tags_variety(): """Test that tools have diverse, meaningful tags.""" data_file = Path("data/initial_tools.json") with data_file.open() as f: tools_data = json.load(f) all_tags = set() for tool_data in tools_data: tool_tags = tool_data["tags"] assert ( len(tool_tags) >= 2 ), f"Tool {tool_data['tool_id']} should have at least 2 tags" all_tags.update(tool_tags) # Should have good tag diversity across 7 tools assert len(all_tags) >= 12, "Should have at least 12 unique tags across all 7 tools" # Check some expected categories are represented in MCP ecosystem expected_categories = {"nlp", "text", "code", "vision", "image", "analysis", "data", "math", "web"} assert expected_categories.intersection( all_tags ), "Should have core technology categories for MCP ecosystem"