22
33from deepset_mcp .api .client import AsyncDeepsetClient
44from deepset_mcp .api .exceptions import ResourceNotFoundError
5- from deepset_mcp .api .pipeline_template .models import PipelineTemplate
5+ from deepset_mcp .api .pipeline_template .models import PipelineTemplate , PipelineTemplateList
66from deepset_mcp .api .pipeline_template .resource import PipelineTemplateResource
77
88pytestmark = pytest .mark .integration
@@ -26,14 +26,14 @@ async def test_get_template(
2626 First lists all templates, then gets the first one by name.
2727 """
2828 # Get all templates to find an existing one
29- templates = await template_resource .list_templates ()
29+ templates_list = await template_resource .list_templates ()
3030
3131 # Skip if no templates are available
32- if not templates :
32+ if not templates_list . data :
3333 pytest .skip ("No templates available in the test environment" )
3434
3535 # Get the first template's name
36- template_name = templates [0 ].template_name
36+ template_name = templates_list . data [0 ].template_name
3737
3838 # Now get that specific template
3939 template = await template_resource .get_template (template_name = template_name )
@@ -64,17 +64,18 @@ async def test_list_templates(
6464) -> None :
6565 """Test listing templates."""
6666 # Test listing templates with default limit
67- templates = await template_resource .list_templates ()
67+ templates_list = await template_resource .list_templates ()
6868
69- # Verify that the templates are returned as a list
70- assert isinstance (templates , list )
69+ # Verify that the templates are returned as a PipelineTemplateList
70+ assert isinstance (templates_list , PipelineTemplateList )
71+ assert isinstance (templates_list .data , list )
7172
7273 # Skip further checks if no templates are available
73- if not templates :
74+ if not templates_list . data :
7475 pytest .skip ("No templates available in the test environment" )
7576
7677 # Verify the first template has the expected structure
77- template = templates [0 ]
78+ template = templates_list . data [0 ]
7879 assert isinstance (template , PipelineTemplate )
7980 assert template .template_name is not None
8081 assert template .author is not None
@@ -89,10 +90,11 @@ async def test_list_templates_with_limit(
8990 """Test listing templates with a specific limit."""
9091 # Test with a small limit
9192 limit = 1
92- templates = await template_resource .list_templates (limit = limit )
93+ templates_list = await template_resource .list_templates (limit = limit )
9394
9495 # Verify that the number of templates is not more than the limit
95- assert len (templates ) <= limit
96+ assert isinstance (templates_list , PipelineTemplateList )
97+ assert len (templates_list .data ) <= limit
9698
9799
98100@pytest .mark .asyncio
@@ -101,24 +103,26 @@ async def test_list_templates_with_filter(
101103) -> None :
102104 """Test listing templates with a pipeline type filter."""
103105 # Test filtering by QUERY pipeline type
104- query_templates = await template_resource .list_templates (filter = "pipeline_type eq 'QUERY'" )
106+ query_templates_list = await template_resource .list_templates (filter = "pipeline_type eq 'QUERY'" )
105107
106108 # Verify that all returned templates are QUERY type
107- assert isinstance (query_templates , list )
109+ assert isinstance (query_templates_list , PipelineTemplateList )
110+ assert isinstance (query_templates_list .data , list )
108111
109112 # If templates are available, verify they are all QUERY type
110- for template in query_templates :
113+ for template in query_templates_list . data :
111114 assert isinstance (template , PipelineTemplate )
112115 assert template .pipeline_type == "query"
113116
114117 # Test filtering by INDEXING pipeline type
115- indexing_templates = await template_resource .list_templates (filter = "pipeline_type eq 'INDEXING'" )
118+ indexing_templates_list = await template_resource .list_templates (filter = "pipeline_type eq 'INDEXING'" )
116119
117120 # Verify that all returned templates are INDEXING type
118- assert isinstance (indexing_templates , list )
121+ assert isinstance (indexing_templates_list , PipelineTemplateList )
122+ assert isinstance (indexing_templates_list .data , list )
119123
120124 # If templates are available, verify they are all INDEXING type
121- for template in indexing_templates :
125+ for template in indexing_templates_list . data :
122126 assert isinstance (template , PipelineTemplate )
123127 assert template .pipeline_type == "indexing"
124128
@@ -129,12 +133,13 @@ async def test_list_templates_with_custom_sorting(
129133) -> None :
130134 """Test listing templates with custom sorting."""
131135 # Test sorting by name in ascending order
132- templates = await template_resource .list_templates (field = "name" , order = "ASC" , limit = 5 )
136+ templates_list = await template_resource .list_templates (field = "name" , order = "ASC" , limit = 5 )
133137
134- # Verify that the templates are returned as a list
135- assert isinstance (templates , list )
138+ # Verify that the templates are returned as a PipelineTemplateList
139+ assert isinstance (templates_list , PipelineTemplateList )
140+ assert isinstance (templates_list .data , list )
136141
137142 # If we have multiple templates, verify they are sorted correctly
138- if len (templates ) > 1 :
139- for i in range (len (templates ) - 1 ):
140- assert templates [i ].display_name <= templates [i + 1 ].display_name
143+ if len (templates_list . data ) > 1 :
144+ for i in range (len (templates_list . data ) - 1 ):
145+ assert templates_list . data [i ].display_name <= templates_list . data [i + 1 ].display_name
0 commit comments