Skip to content

Commit 881538d

Browse files
committed
fix(agentgateway): align gtids rename across fragments, tests and docstrings
- Fix ConnectedSystem construction to use global_tenant_id (not gtids) - Rename list_mcp_fragments param global_tenant_ids → gtids in tests - Replace GTID_LABEL_KEY usage with string literal in test_lob.py - Update test names and MCPToolFilter usages to use gtids field - Fix agw_client.py docstring example to use gtids instead of global_tenant_ids
1 parent 804e3ec commit 881538d

5 files changed

Lines changed: 19 additions & 22 deletions

File tree

src/sap_cloud_sdk/agentgateway/_fragments.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
def _list_fragments_by_label(
3838
label: FragmentLabel,
3939
tenant_subdomain: str,
40-
global_tenant_ids: list[str] | None = None,
40+
gtids: list[str] | None = None,
4141
) -> list:
4242
filter_labels = [Label(key=LABEL_KEY, values=[label.value])]
43-
if global_tenant_ids:
44-
filter_labels.append(Label(key=_LABEL_GTID, values=global_tenant_ids))
43+
if gtids:
44+
filter_labels.append(Label(key=_LABEL_GTID, values=gtids))
4545
client = create_fragment_client(
4646
instance=_DESTINATION_INSTANCE,
4747
_telemetry_source=Module.AGENTGATEWAY,
@@ -54,13 +54,13 @@ def _list_fragments_by_label(
5454

5555
def list_mcp_fragments(
5656
tenant_subdomain: str,
57-
global_tenant_ids: list[str] | None = None,
57+
gtids: list[str] | None = None,
5858
) -> list:
5959
"""List destination fragments with MCP server label.
6060
6161
Args:
6262
tenant_subdomain: Tenant subdomain for multi-tenant lookup.
63-
global_tenant_ids: Optional list of global tenant IDs of integrated
63+
gtids: Optional list of global tenant IDs of integrated
6464
systems to filter by. When set, only fragments whose
6565
``sap-managed-runtime-gtid`` label matches one of these values are
6666
returned (filter is applied server-side by the Destination Service).
@@ -71,7 +71,7 @@ def list_mcp_fragments(
7171
"""
7272
logger.debug("Fetching MCP fragments for tenant '%s'", tenant_subdomain)
7373
return _list_fragments_by_label(
74-
FragmentLabel.MCP, tenant_subdomain, global_tenant_ids
74+
FragmentLabel.MCP, tenant_subdomain, gtids
7575
)
7676

7777

@@ -136,9 +136,6 @@ def get_ias_user_fragment_name(tenant_subdomain: str) -> str:
136136
return fragments[0].name
137137

138138

139-
# Backward-compatible alias
140-
ActiveIntegration = ConnectedSystem
141-
142139

143140
def _list_active_integrations(tenant_subdomain: str) -> list[ConnectedSystem]:
144141
"""List all active backend system integrations for the given tenant.

src/sap_cloud_sdk/agentgateway/agw_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ async def list_mcp_tools(
403403
filter=MCPToolFilter(
404404
names=["get-sales-order"],
405405
ord_ids=["sap.s4:apiAccess:salesOrder:v1"],
406-
global_tenant_ids=["<gtid>"],
406+
gtids=["<gtid>"],
407407
)
408408
)
409409
```

tests/agentgateway/unit/test_agw_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ async def test_with_callable_tenant(self):
448448
)
449449

450450
@pytest.mark.asyncio
451-
async def test_forwards_global_tenant_ids_from_filter_to_lob(self):
452-
"""MCPToolFilter.global_tenant_ids should reach get_mcp_tools_lob."""
451+
async def test_forwards_gtids_from_filter_to_lob(self):
452+
"""MCPToolFilter.gtids should reach get_mcp_tools_lob."""
453453
with (
454454
patch(
455455
"sap_cloud_sdk.agentgateway.agw_client.detect_customer_agent_credentials",
@@ -473,14 +473,14 @@ async def test_forwards_global_tenant_ids_from_filter_to_lob(self):
473473
agw_client = create_client(tenant_subdomain="my-tenant")
474474

475475
await agw_client.list_mcp_tools(
476-
filter=MCPToolFilter(global_tenant_ids=["gtid-a", "gtid-b"]),
476+
filter=MCPToolFilter(gtids=["gtid-a", "gtid-b"]),
477477
)
478478

479479
mock_lob.assert_called_once_with(
480480
"my-tenant",
481481
"system-token",
482482
60.0,
483-
filter=MCPToolFilter(global_tenant_ids=["gtid-a", "gtid-b"]),
483+
filter=MCPToolFilter(gtids=["gtid-a", "gtid-b"]),
484484
)
485485

486486
@pytest.mark.asyncio

tests/agentgateway/unit/test_fragments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _full_labels(gtid: str, system_type: str, ord_id: str) -> list[Label]:
3636
# ============================================================
3737

3838

39-
class TestListActiveIntegrations:
39+
class TestListConnectedSystems:
4040
def test_returns_entries_from_fragment_labels(self):
4141
frag1 = _fragment("frag-mcp-1")
4242
frag2 = _fragment("frag-a2a-2")
@@ -209,7 +209,7 @@ def test_filters_by_mcp_label_type_only(self):
209209
# ============================================================
210210

211211

212-
class TestAgentGatewayClientListActiveIntegrations:
212+
class TestAgentGatewayClientListConnectedSystems:
213213
def test_delegates_to_fragments_helper(self):
214214
expected = [
215215
{

tests/agentgateway/unit/test_lob.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,31 +230,31 @@ def test_uses_correct_filter_labels(self):
230230
assert filter_opt.filter_labels[0].key == _LABEL_KEY
231231
assert filter_opt.filter_labels[0].values == [_MCP_LABEL_VALUE]
232232

233-
def test_adds_gtid_label_when_global_tenant_ids_provided(self):
234-
"""When global_tenant_ids is set, add a gtid label to the filter."""
233+
def test_adds_gtid_label_when_gtids_provided(self):
234+
"""When gtids is set, add a gtid label to the filter."""
235235
with patch(
236236
"sap_cloud_sdk.agentgateway._fragments.create_fragment_client"
237237
) as mock_client:
238238
mock_client.return_value.list_instance_fragments.return_value = []
239239

240-
list_mcp_fragments("tenant-sub", global_tenant_ids=["gtid-a", "gtid-b"])
240+
list_mcp_fragments("tenant-sub", gtids=["gtid-a", "gtid-b"])
241241

242242
call_args = mock_client.return_value.list_instance_fragments.call_args
243243
filter_opt = call_args.kwargs.get("filter")
244244
assert len(filter_opt.filter_labels) == 2
245245
gtid_label = next(
246-
lb for lb in filter_opt.filter_labels if lb.key == GTID_LABEL_KEY
246+
lb for lb in filter_opt.filter_labels if lb.key == "sap-managed-runtime-gtid"
247247
)
248248
assert gtid_label.values == ["gtid-a", "gtid-b"]
249249

250-
def test_omits_gtid_label_when_global_tenant_ids_is_empty(self):
250+
def test_omits_gtid_label_when_gtids_is_empty(self):
251251
"""Empty list is treated the same as None — no gtid label added."""
252252
with patch(
253253
"sap_cloud_sdk.agentgateway._fragments.create_fragment_client"
254254
) as mock_client:
255255
mock_client.return_value.list_instance_fragments.return_value = []
256256

257-
list_mcp_fragments("tenant-sub", global_tenant_ids=[])
257+
list_mcp_fragments("tenant-sub", gtids=[])
258258

259259
call_args = mock_client.return_value.list_instance_fragments.call_args
260260
filter_opt = call_args.kwargs.get("filter")

0 commit comments

Comments
 (0)