mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2026-08-04 08:56:50 +00:00
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>
286 lines
10 KiB
Python
286 lines
10 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Endpoint Tests API
|
|
|
|
Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API.
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import thousandeyes_sdk.endpoint_tests.models
|
|
|
|
from thousandeyes_sdk.core.exceptions import ApiException
|
|
from thousandeyes_sdk.endpoint_tests.api.endpoint_scheduled_tests_api import EndpointScheduledTestsApi
|
|
from .integration_test_utils import IntegrationTestBase
|
|
from .test_utils import assert_constructed_model_matches_example_json
|
|
|
|
|
|
class TestEndpointScheduledTestsApiIntegration(IntegrationTestBase):
|
|
"""EndpointScheduledTestsApi integration test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.api = EndpointScheduledTestsApi(self.api_client)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests success path"""
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"tests" : [ {
|
|
"server" : "www.example.com",
|
|
"isSavedEvent" : false,
|
|
"_links" : {
|
|
"testResults" : [ {
|
|
"href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter"
|
|
}, {
|
|
"href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis"
|
|
} ],
|
|
"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"
|
|
}
|
|
},
|
|
"isPrioritized" : false,
|
|
"networkMeasurements" : true,
|
|
"type" : "agent-to-server",
|
|
"tcpProbeMode" : "auto",
|
|
"labels" : [ {
|
|
"labelId" : "961",
|
|
"name" : "Artem label",
|
|
"isBuiltin" : false
|
|
}, {
|
|
"labelId" : "961",
|
|
"name" : "Artem label",
|
|
"isBuiltin" : false
|
|
} ],
|
|
"protocol" : "icmp",
|
|
"createdDate" : "2022-07-17T22:00:54Z",
|
|
"ipVersion" : "V4_ONLY",
|
|
"port" : 443,
|
|
"isEnabled" : true,
|
|
"modifiedDate" : "2022-07-17T22:00:54Z",
|
|
"interval" : 60,
|
|
"testId" : "281474976710706",
|
|
"aid" : "1234",
|
|
"agentSelectorConfig" : {
|
|
"agentSelectorType" : "all-agents",
|
|
"maxMachines" : 25
|
|
},
|
|
"hasPathTraceInSession" : true,
|
|
"testName" : "Test name"
|
|
}, {
|
|
"server" : "www.example.com",
|
|
"isSavedEvent" : false,
|
|
"_links" : {
|
|
"testResults" : [ {
|
|
"href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter"
|
|
}, {
|
|
"href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis"
|
|
} ],
|
|
"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"
|
|
}
|
|
},
|
|
"isPrioritized" : false,
|
|
"networkMeasurements" : true,
|
|
"type" : "agent-to-server",
|
|
"tcpProbeMode" : "auto",
|
|
"labels" : [ {
|
|
"labelId" : "961",
|
|
"name" : "Artem label",
|
|
"isBuiltin" : false
|
|
}, {
|
|
"labelId" : "961",
|
|
"name" : "Artem label",
|
|
"isBuiltin" : false
|
|
} ],
|
|
"protocol" : "icmp",
|
|
"createdDate" : "2022-07-17T22:00:54Z",
|
|
"ipVersion" : "V4_ONLY",
|
|
"port" : 443,
|
|
"isEnabled" : true,
|
|
"modifiedDate" : "2022-07-17T22:00:54Z",
|
|
"interval" : 60,
|
|
"testId" : "281474976710706",
|
|
"aid" : "1234",
|
|
"agentSelectorConfig" : {
|
|
"agentSelectorType" : "all-agents",
|
|
"maxMachines" : 25
|
|
},
|
|
"hasPathTraceInSession" : true,
|
|
"testName" : "Test name"
|
|
} ],
|
|
"_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"
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests 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_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests error path (HTTP 403)"""
|
|
aid = '1234'
|
|
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_endpoint_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests error path (HTTP 429)"""
|
|
aid = '1234'
|
|
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_endpoint_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_error_500(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests error path (HTTP 500)"""
|
|
aid = '1234'
|
|
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_endpoint_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_scheduled_tests_error_502(self) -> None:
|
|
"""Integration test for get_endpoint_scheduled_tests error path (HTTP 502)"""
|
|
aid = '1234'
|
|
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_endpoint_scheduled_tests(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_scheduled_tests", error_status="502"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|