Skip to content

Commit 303fbe3

Browse files
authored
Merge pull request lightspeed-core#1557 from tisnik/lcore-1954-fixed-missing-arguments-to-mcp-unit-tests
LCORE-1954: Fixed missing arguments to MCP in unit tests
2 parents a40e0a0 + f904f91 commit 303fbe3

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

tests/unit/app/endpoints/test_mcp_servers.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ async def test_register_mcp_server_success(
116116
body = MCPServerRegistrationRequest(
117117
name="new-mcp-server",
118118
url="http://localhost:8888/mcp",
119+
provider_id="MCP provider ID",
119120
)
120121

121122
result = await mcp_servers.register_mcp_server_handler(
@@ -125,12 +126,12 @@ async def test_register_mcp_server_success(
125126
assert isinstance(result, MCPServerRegistrationResponse)
126127
assert result.name == "new-mcp-server"
127128
assert result.url == "http://localhost:8888/mcp"
128-
assert result.provider_id == "model-context-protocol"
129+
assert result.provider_id == "MCP provider ID"
129130
assert "registered successfully" in result.message
130131

131132
client.toolgroups.register.assert_called_once_with(
132133
toolgroup_id="new-mcp-server",
133-
provider_id="model-context-protocol",
134+
provider_id="MCP provider ID",
134135
mcp_endpoint={"uri": "http://localhost:8888/mcp"},
135136
)
136137

@@ -150,6 +151,7 @@ async def test_register_mcp_server_duplicate_name(
150151
body = MCPServerRegistrationRequest(
151152
name="static-mcp",
152153
url="http://localhost:9999/mcp",
154+
provider_id="MCP provider ID",
153155
)
154156

155157
with pytest.raises(HTTPException) as exc_info:
@@ -172,6 +174,7 @@ async def test_register_mcp_server_llama_stack_failure(
172174
body = MCPServerRegistrationRequest(
173175
name="failing-server",
174176
url="http://localhost:8888/mcp",
177+
provider_id="MCP provider ID",
175178
)
176179

177180
with pytest.raises(HTTPException) as exc_info:
@@ -242,6 +245,7 @@ async def test_list_mcp_servers_with_dynamic(
242245
body = MCPServerRegistrationRequest(
243246
name="dynamic-server",
244247
url="http://localhost:9999/mcp",
248+
provider_id="MCP provider ID",
245249
)
246250
await mcp_servers.register_mcp_server_handler(
247251
request=mocker.Mock(), body=body, auth=MOCK_AUTH
@@ -271,6 +275,7 @@ async def test_delete_dynamic_mcp_server_success(
271275
body = MCPServerRegistrationRequest(
272276
name="to-delete",
273277
url="http://localhost:7777/mcp",
278+
provider_id="MCP provider ID",
274279
)
275280
await mcp_servers.register_mcp_server_handler(
276281
request=mocker.Mock(), body=body, auth=MOCK_AUTH
@@ -337,6 +342,7 @@ async def test_delete_mcp_server_llama_stack_failure(
337342
body = MCPServerRegistrationRequest(
338343
name="to-delete-fail",
339344
url="http://localhost:7777/mcp",
345+
provider_id="MCP provider ID",
340346
)
341347
await mcp_servers.register_mcp_server_handler(
342348
request=mocker.Mock(), body=body, auth=MOCK_AUTH
@@ -355,18 +361,20 @@ def test_mcp_server_registration_request_validation() -> None:
355361
MCPServerRegistrationRequest(
356362
name="test",
357363
url="ftp://invalid-scheme",
364+
provider_id="MCP provider ID",
358365
)
359366

360367
with pytest.raises(Exception):
361368
MCPServerRegistrationRequest(
362369
name="",
363370
url="http://valid.url",
371+
provider_id="MCP provider ID",
364372
)
365373

366374
req = MCPServerRegistrationRequest(
367375
name="valid-server",
368376
url="http://localhost:8080/mcp",
369-
)
377+
) # pyright: ignore[reportCallIssue]
370378
assert req.provider_id == "model-context-protocol"
371379

372380

@@ -377,6 +385,7 @@ def test_mcp_server_registration_auth_keywords() -> None:
377385
name=f"server-{keyword}",
378386
url="http://localhost:8080/mcp",
379387
authorization_headers={"Authorization": keyword},
388+
provider_id="MCP provider ID",
380389
)
381390
assert req.authorization_headers is not None
382391
assert req.authorization_headers["Authorization"] == keyword
@@ -389,6 +398,7 @@ def test_mcp_server_registration_rejects_file_path() -> None:
389398
name="bad-server",
390399
url="http://localhost:8080/mcp",
391400
authorization_headers={"Authorization": "/var/secrets/token"},
401+
provider_id="MCP provider ID",
392402
)
393403

394404

@@ -399,6 +409,7 @@ def test_mcp_server_registration_rejects_arbitrary_value() -> None:
399409
name="bad-server",
400410
url="http://localhost:8080/mcp",
401411
authorization_headers={"Authorization": "Bearer my-static-token"},
412+
provider_id="MCP provider ID",
402413
)
403414

404415

@@ -416,6 +427,7 @@ async def test_register_and_delete_roundtrip(
416427
body = MCPServerRegistrationRequest(
417428
name="roundtrip-server",
418429
url="http://localhost:5555/mcp",
430+
provider_id="MCP provider ID",
419431
)
420432
await mcp_servers.register_mcp_server_handler(
421433
request=mocker.Mock(), body=body, auth=MOCK_AUTH

0 commit comments

Comments
 (0)