Skip to content

Commit 0fafc5c

Browse files
authored
Merge pull request lightspeed-core#290 from umago/mcp-unit-tests
Make MCP configurations unit-test more specific
2 parents c1c7ba3 + daeb64f commit 0fafc5c

1 file changed

Lines changed: 25 additions & 127 deletions

File tree

tests/unit/models/test_config.py

Lines changed: 25 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,7 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
574574
),
575575
mcp_servers=mcp_servers,
576576
customization=None,
577-
inference=InferenceConfiguration(
578-
default_provider="default_provider",
579-
default_model="default_model",
580-
),
577+
inference=None,
581578
)
582579
dump_file = tmp_path / "test.json"
583580
cfg.dump(dump_file)
@@ -591,62 +588,14 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
591588
assert content["mcp_servers"][0]["url"] == "http://localhost:8080"
592589
assert content["mcp_servers"][0]["provider_id"] == "model-context-protocol"
593590

594-
# check the whole deserialized JSON file content
595-
assert content == {
596-
"name": "test_name",
597-
"service": {
598-
"host": "localhost",
599-
"port": 8080,
600-
"auth_enabled": False,
601-
"workers": 1,
602-
"color_log": True,
603-
"access_log": True,
604-
"tls_config": {
605-
"tls_certificate_path": None,
606-
"tls_key_path": None,
607-
"tls_key_password": None,
608-
},
609-
},
610-
"llama_stack": {
611-
"url": None,
612-
"api_key": None,
613-
"use_as_library_client": True,
614-
"library_client_config_path": "tests/configuration/run.yaml",
615-
},
616-
"user_data_collection": {
617-
"feedback_enabled": False,
618-
"feedback_storage": None,
619-
"transcripts_enabled": False,
620-
"transcripts_storage": None,
621-
"data_collector": {
622-
"enabled": False,
623-
"ingress_server_url": None,
624-
"ingress_server_auth_token": None,
625-
"ingress_content_service_name": None,
626-
"collection_interval": DATA_COLLECTOR_COLLECTION_INTERVAL,
627-
"cleanup_after_send": True,
628-
"connection_timeout": DATA_COLLECTOR_CONNECTION_TIMEOUT,
629-
},
630-
},
631-
"mcp_servers": [
632-
{
633-
"name": "test-server",
634-
"provider_id": "model-context-protocol",
635-
"url": "http://localhost:8080",
636-
},
637-
],
638-
"authentication": {
639-
"module": "noop",
640-
"skip_tls_verification": False,
641-
"k8s_ca_cert_path": None,
642-
"k8s_cluster_api": None,
643-
},
644-
"customization": None,
645-
"inference": {
646-
"default_provider": "default_provider",
647-
"default_model": "default_model",
648-
},
649-
}
591+
# check the MCP server configuration
592+
assert content["mcp_servers"] == [
593+
{
594+
"name": "test-server",
595+
"url": "http://localhost:8080",
596+
"provider_id": "model-context-protocol",
597+
}
598+
]
650599

651600

652601
def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
@@ -676,10 +625,7 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
676625
),
677626
mcp_servers=mcp_servers,
678627
customization=None,
679-
inference=InferenceConfiguration(
680-
default_provider="default_provider",
681-
default_model="default_model",
682-
),
628+
inference=None,
683629
)
684630
dump_file = tmp_path / "test.json"
685631
cfg.dump(dump_file)
@@ -699,72 +645,24 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
699645
assert content["mcp_servers"][2]["url"] == "http://localhost:8083"
700646
assert content["mcp_servers"][2]["provider_id"] == "model-context-protocol"
701647

702-
# check the whole deserialized JSON file content
703-
assert content == {
704-
"name": "test_name",
705-
"service": {
706-
"host": "localhost",
707-
"port": 8080,
708-
"auth_enabled": False,
709-
"workers": 1,
710-
"color_log": True,
711-
"access_log": True,
712-
"tls_config": {
713-
"tls_certificate_path": None,
714-
"tls_key_path": None,
715-
"tls_key_password": None,
716-
},
648+
# check the MCP server configuration
649+
assert content["mcp_servers"] == [
650+
{
651+
"name": "test-server-1",
652+
"provider_id": "model-context-protocol",
653+
"url": "http://localhost:8081",
717654
},
718-
"llama_stack": {
719-
"url": None,
720-
"api_key": None,
721-
"use_as_library_client": True,
722-
"library_client_config_path": "tests/configuration/run.yaml",
655+
{
656+
"name": "test-server-2",
657+
"provider_id": "model-context-protocol",
658+
"url": "http://localhost:8082",
723659
},
724-
"user_data_collection": {
725-
"feedback_enabled": False,
726-
"feedback_storage": None,
727-
"transcripts_enabled": False,
728-
"transcripts_storage": None,
729-
"data_collector": {
730-
"enabled": False,
731-
"ingress_server_url": None,
732-
"ingress_server_auth_token": None,
733-
"ingress_content_service_name": None,
734-
"collection_interval": DATA_COLLECTOR_COLLECTION_INTERVAL,
735-
"cleanup_after_send": True,
736-
"connection_timeout": DATA_COLLECTOR_CONNECTION_TIMEOUT,
737-
},
738-
},
739-
"mcp_servers": [
740-
{
741-
"name": "test-server-1",
742-
"provider_id": "model-context-protocol",
743-
"url": "http://localhost:8081",
744-
},
745-
{
746-
"name": "test-server-2",
747-
"provider_id": "model-context-protocol",
748-
"url": "http://localhost:8082",
749-
},
750-
{
751-
"name": "test-server-3",
752-
"provider_id": "model-context-protocol",
753-
"url": "http://localhost:8083",
754-
},
755-
],
756-
"authentication": {
757-
"module": "noop",
758-
"skip_tls_verification": False,
759-
"k8s_ca_cert_path": None,
760-
"k8s_cluster_api": None,
660+
{
661+
"name": "test-server-3",
662+
"provider_id": "model-context-protocol",
663+
"url": "http://localhost:8083",
761664
},
762-
"customization": None,
763-
"inference": {
764-
"default_provider": "default_provider",
765-
"default_model": "default_model",
766-
},
767-
}
665+
]
768666

769667

770668
def test_authentication_configuration() -> None:

0 commit comments

Comments
 (0)