thousandeyes-sdk-python/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_transfer_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

319 lines
11 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_agents_transfer_api import EndpointAgentsTransferApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestEndpointAgentsTransferApiIntegration(IntegrationTestBase):
"""EndpointAgentsTransferApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = EndpointAgentsTransferApi(self.api_client)
def test_transfer_endpoint_agents_happy_path(self) -> None:
"""Integration test for transfer_endpoint_agents success path"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
aid = '1234'
response_body_json = """
{
"items" : [ {
"status" : 200,
"detail" : "Initiated",
"request" : {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}
}, {
"status" : 400,
"detail" : "Missing from-account id",
"request" : {
"agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed1234",
"fromAid" : "xxx",
"toAid" : "12345"
}
}, {
"status" : 403,
"detail" : "User does not have permission on 'to' aid",
"request" : {
"agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed7890",
"fromAid" : "1234",
"toAid" : "12345"
}
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_transfer_endpoint_agents_error_400(self) -> None:
"""Integration test for transfer_endpoint_agents error path (HTTP 400)"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_transfer_endpoint_agents_error_401(self) -> None:
"""Integration test for transfer_endpoint_agents error path (HTTP 401)"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
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.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_transfer_endpoint_agents_error_403(self) -> None:
"""Integration test for transfer_endpoint_agents error path (HTTP 403)"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
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.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_transfer_endpoint_agents_error_404(self) -> None:
"""Integration test for transfer_endpoint_agents error path (HTTP 404)"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
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(404)
) as context:
self.api.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_transfer_endpoint_agents_error_429(self) -> None:
"""Integration test for transfer_endpoint_agents error path (HTTP 429)"""
request_body_json = """
{
"transfers" : [ {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
}, {
"agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba",
"fromAid" : "1234",
"toAid" : "12345"
} ]
}
"""
bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json)
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.transfer_endpoint_agents(
aid=aid,
bulk_agent_transfer_request=bulk_agent_transfer_request,
_headers=self.te_headers("transfer_endpoint_agents", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()