File size: 2,571 Bytes
1f2d50a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64ced8b
1f2d50a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64ced8b
 
1f2d50a
64ced8b
1f2d50a
 
 
64ced8b
 
 
 
 
 
1f2d50a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64ced8b
 
1f2d50a
64ced8b
 
1f2d50a
 
64ced8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""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"