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

345 lines
11 KiB
Python

# coding: utf-8
"""
Agents API
## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes.
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.agents.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.agents.api.local_problems_api import LocalProblemsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestLocalProblemsApiIntegration(IntegrationTestBase):
"""LocalProblemsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = LocalProblemsApi(self.api_client)
def test_get_agents_local_problems_happy_path(self) -> None:
"""Integration test for get_agents_local_problems success path"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
response_body_json = """
{
"endDate" : "2022-07-18T22:00:54Z",
"_links" : {
"self" : {
"hreflang" : "hreflang",
"templated" : true,
"profile" : "profile",
"name" : "name",
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
"type" : "type",
"deprecation" : "deprecation",
"title" : "title"
}
},
"localProblems" : [ {
"duration" : 480,
"agent" : {
"agentId" : "281474976710706",
"agentName" : "thousandeyes-stg-va-254",
"location" : "San Francisco Bay Area",
"countryId" : "US"
},
"endDate" : "2026-05-18T03:22:00Z",
"active" : false,
"startDate" : "2026-05-18T03:14:00Z"
}, {
"duration" : 480,
"agent" : {
"agentId" : "281474976710706",
"agentName" : "thousandeyes-stg-va-254",
"location" : "San Francisco Bay Area",
"countryId" : "US"
},
"endDate" : "2026-05-18T03:22:00Z",
"active" : false,
"startDate" : "2026-05-18T03:14:00Z"
} ],
"startDate" : "2022-07-17T22:00:54Z"
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_agents_local_problems_error_400(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 400)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
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.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_401(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 401)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
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_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_403(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 403)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(403)
) as context:
self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_404(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 404)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(404)
) as context:
self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_429(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 429)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(429)
) as context:
self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_500(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 500)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(500)
) as context:
self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_agents_local_problems_error_502(self) -> None:
"""Integration test for get_agents_local_problems error path (HTTP 502)"""
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(502)
) as context:
self.api.get_agents_local_problems(
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_agents_local_problems", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()