thousandeyes-sdk-python/thousandeyes-sdk-endpoint-agents/test/test_endpoint_proxies_api_integration.py
Kevin b1faff026e Regenerate integration tests with fixed JSON escaping and enum params.
Success response bodies now use valid JSON quotes instead of HTML entities,
and optional expand enum params are omitted when OpenAPI examples are invalid.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 12:13:24 +01:00

177 lines
6.2 KiB
Python

# coding: utf-8
"""
Endpoint Agents API
**Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents).
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.endpoint_agents.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.endpoint_agents.api.endpoint_proxies_api import EndpointProxiesApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestEndpointProxiesApiIntegration(IntegrationTestBase):
"""EndpointProxiesApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = EndpointProxiesApi(self.api_client)
def test_get_endpoint_proxies_happy_path(self) -> None:
"""Integration test for get_endpoint_proxies success path"""
aid = '1234'
response_body_json = """
{
"proxies" : [ {
"testIds" : [ "9923667", "9923667" ],
"agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
"pac" : "https://example.com/proxy.pac",
"port" : 8080,
"name" : "Local Mitmproxy",
"host" : "localhost",
"type" : "static",
"userName" : "endpoint-proxy-user",
"authType" : "none",
"bypassList" : "localhost,127.0.0.1",
"proxyId" : "101498"
}, {
"testIds" : [ "9923667", "9923667" ],
"agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
"pac" : "https://example.com/proxy.pac",
"port" : 8080,
"name" : "Local Mitmproxy",
"host" : "localhost",
"type" : "static",
"userName" : "endpoint-proxy-user",
"authType" : "none",
"bypassList" : "localhost,127.0.0.1",
"proxyId" : "101498"
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_endpoint_proxies(
aid=aid,
_headers=self.te_headers("get_endpoint_proxies"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_endpoint_proxies_error_401(self) -> None:
"""Integration test for get_endpoint_proxies error path (HTTP 401)"""
aid = '1234'
error_body_json = """
{
"error_description" : "Invalid access token",
"error" : "invalid_token"
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(401)
) as context:
self.api.get_endpoint_proxies(
aid=aid,
_headers=self.te_headers("get_endpoint_proxies", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_proxies_error_403(self) -> None:
"""Integration test for get_endpoint_proxies error path (HTTP 403)"""
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 6
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(403)
) as context:
self.api.get_endpoint_proxies(
aid=aid,
_headers=self.te_headers("get_endpoint_proxies", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_proxies_error_429(self) -> None:
"""Integration test for get_endpoint_proxies error path (HTTP 429)"""
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 6
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(429)
) as context:
self.api.get_endpoint_proxies(
aid=aid,
_headers=self.te_headers("get_endpoint_proxies", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_proxies_error_500(self) -> None:
"""Integration test for get_endpoint_proxies error path (HTTP 500)"""
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 6
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(500)
) as context:
self.api.get_endpoint_proxies(
aid=aid,
_headers=self.te_headers("get_endpoint_proxies", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()