Skip to content

Commit 04d729b

Browse files
Add test for unsupported endpoint
1 parent f12c02f commit 04d729b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/test_api_endpoint_config.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99
import os
1010
from urllib.parse import urlparse
11-
from seclab_taskflow_agent.capi import get_AI_endpoint, AI_API_ENDPOINT_ENUM
11+
from seclab_taskflow_agent.capi import get_AI_endpoint, AI_API_ENDPOINT_ENUM, list_capi_models
1212

1313
class TestAPIEndpoint:
1414
"""Test API endpoint configuration."""
@@ -51,5 +51,19 @@ def test_to_url_githubcopilot(self):
5151
endpoint = AI_API_ENDPOINT_ENUM.AI_API_GITHUBCOPILOT
5252
assert endpoint.to_url() == 'https://api.githubcopilot.com'
5353

54+
def test_unsupported_endpoint(self):
55+
original_env = os.environ.pop('AI_API_ENDPOINT', None)
56+
api_endpoint = 'https://unsupported.example.com'
57+
os.environ['AI_API_ENDPOINT'] = api_endpoint
58+
59+
with pytest.raises(ValueError) as excinfo:
60+
list_capi_models("abc")
61+
msg = str(excinfo.value)
62+
assert 'Unsupported Model Endpoint' in msg
63+
assert 'https://models.github.ai/inference' in msg
64+
assert 'https://api.githubcopilot.com' in msg
65+
if original_env:
66+
os.environ['AI_API_ENDPOINT'] = original_env
67+
5468
if __name__ == '__main__':
5569
pytest.main([__file__, '-v'])

0 commit comments

Comments
 (0)