forked from box-community/mcp-server-box
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_box_tools_groups.py
More file actions
55 lines (47 loc) · 1.87 KB
/
Copy pathtest_box_tools_groups.py
File metadata and controls
55 lines (47 loc) · 1.87 KB
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
from unittest.mock import MagicMock, patch
import pytest
from mcp.server.fastmcp import Context
from tools.box_tools_groups import (
box_groups_list_by_user_tool,
box_groups_list_members_tool,
box_groups_search_tool,
)
@pytest.mark.asyncio
async def test_box_groups_search_tool():
ctx = MagicMock(spec=Context)
query = "Test Group"
with (
patch("tools.box_tools_groups.box_groups_search") as mock_search,
patch("tools.box_tools_groups.get_box_client") as mock_get_client,
):
mock_get_client.return_value = "client"
mock_search.return_value = [{"id": "1", "name": query}]
result = await box_groups_search_tool(ctx, query)
assert isinstance(result, list)
assert result[0]["name"] == query
@pytest.mark.asyncio
async def test_box_groups_list_members_tool():
ctx = MagicMock(spec=Context)
group_id = "12345"
with (
patch("tools.box_tools_groups.box_groups_list_members") as mock_list,
patch("tools.box_tools_groups.get_box_client") as mock_get_client,
):
mock_get_client.return_value = "client"
mock_list.return_value = [{"id": "1", "name": "Member User"}]
result = await box_groups_list_members_tool(ctx, group_id)
assert isinstance(result, list)
assert result[0]["name"] == "Member User"
@pytest.mark.asyncio
async def test_box_groups_list_by_user_tool():
ctx = MagicMock(spec=Context)
user_id = "67890"
with (
patch("tools.box_tools_groups.box_groups_list_by_user") as mock_list,
patch("tools.box_tools_groups.get_box_client") as mock_get_client,
):
mock_get_client.return_value = "client"
mock_list.return_value = [{"id": "1", "name": "User Group"}]
result = await box_groups_list_by_user_tool(ctx, user_id)
assert isinstance(result, list)
assert result[0]["name"] == "User Group"