Skip to content

Commit 98a02b1

Browse files
authored
fix(agentgateway): skip integration tests when AGW not subscribed for tenant (#168)
1 parent ab61594 commit 98a02b1

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

tests/agentgateway/integration/conftest.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from dotenv import load_dotenv
88

99
from sap_cloud_sdk.agentgateway import create_client, AgentGatewayClient
10+
from sap_cloud_sdk.agentgateway.exceptions import MCPServerNotFoundError
1011

1112

1213
def _setup_cloud_mode():
@@ -23,14 +24,16 @@ def agw_client() -> AgentGatewayClient:
2324

2425
tenant_subdomain = os.environ.get("CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN")
2526
if not tenant_subdomain:
26-
pytest.fail("CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN environment variable is not set")
27+
pytest.skip("CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN is not set — skipping AGW integration tests")
2728

2829
landscape = os.environ.get("CLOUD_SDK_CFG_AGW_DEFAULT_LANDSCAPE")
2930
if landscape:
3031
os.environ.setdefault("APPFND_CONHOS_LANDSCAPE", landscape)
3132

3233
try:
3334
return create_client(tenant_subdomain=tenant_subdomain)
35+
except MCPServerNotFoundError as e:
36+
pytest.skip(f"AGW not subscribed for this tenant — skipping AGW integration tests: {e}")
3437
except Exception as e:
3538
pytest.fail(f"Failed to create Agent Gateway client for integration tests: {e}")
3639

@@ -49,3 +52,11 @@ def pytest_collection_modifyitems(config, items):
4952
for item in items:
5053
if "integration" in str(item.fspath):
5154
item.add_marker(pytest.mark.integration)
55+
56+
57+
def pytest_runtest_call(item):
58+
"""Skip AGW tests that fail due to missing subscription."""
59+
try:
60+
item.runtest()
61+
except MCPServerNotFoundError as e:
62+
pytest.skip(f"AGW not subscribed for this tenant — skipping: {e}")

tests/dms/integration/conftest.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from sap_cloud_sdk.dms import create_client
2+
from sap_cloud_sdk.dms.exceptions import DMSError
23
from sap_cloud_sdk.dms.model import InternalRepoRequest
34
import pytest
45
import logging
@@ -33,22 +34,25 @@ def _setup_test_repositories(dms_client):
3334
created_repos = []
3435

3536
logger.info("Onboarding test repositories")
36-
repo = dms_client.onboard_repository(
37-
InternalRepoRequest(
38-
displayName=f"{_SDK_TEST_REPO_PREFIX}standard",
39-
description="Auto-created by SDK integration tests",
37+
try:
38+
repo = dms_client.onboard_repository(
39+
InternalRepoRequest(
40+
displayName=f"{_SDK_TEST_REPO_PREFIX}standard",
41+
description="Auto-created by SDK integration tests",
42+
)
4043
)
41-
)
42-
created_repos.append(repo.id)
44+
created_repos.append(repo.id)
4345

44-
repo = dms_client.onboard_repository(
45-
InternalRepoRequest(
46-
displayName=f"{_SDK_TEST_REPO_PREFIX}versioned",
47-
description="Auto-created by SDK integration tests (versioning)",
48-
isVersionEnabled=True,
46+
repo = dms_client.onboard_repository(
47+
InternalRepoRequest(
48+
displayName=f"{_SDK_TEST_REPO_PREFIX}versioned",
49+
description="Auto-created by SDK integration tests (versioning)",
50+
isVersionEnabled=True,
51+
)
4952
)
50-
)
51-
created_repos.append(repo.id)
53+
created_repos.append(repo.id)
54+
except DMSError as e:
55+
pytest.skip(f"DMS ECM repository connection not available — skipping DMS integration tests: {e}")
5256

5357
yield
5458

0 commit comments

Comments
 (0)