thousandeyes-sdk-python/thousandeyes-sdk-test-results/test/test_network_test_results_api_integration.py
Kevin 5441f44f1f CP-2453 Add generated integration tests for all SDK packages
Sync OAS-driven integration test artifacts (mock manifest, test base, conftest, and per-operation integration tests) across 21 packages for CP-2453 full rollout evaluation.

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

1337 lines
60 KiB
Python

# coding: utf-8
"""
Test Results API
Get test result metrics for Network and Application Synthetics tests.
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.test_results.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.test_results.api.network_test_results_api import NetworkTestResultsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestNetworkTestResultsApiIntegration(IntegrationTestBase):
"""NetworkTestResultsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = NetworkTestResultsApi(self.api_client)
def test_get_test_network_results_happy_path(self) -> None:
"""Integration test for get_test_network_results success path"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
response_body_json = """
{
&quot;test&quot; : {
&quot;_links&quot; : {
&quot;testResults&quot; : [ {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/network&quot;
}, {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis&quot;
} ],
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;liveShare&quot; : false,
&quot;savedEvent&quot; : true,
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;type&quot; : &quot;agent-to-server&quot;,
&quot;enabled&quot; : true,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;alertsEnabled&quot; : true,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;
},
&quot;endDate&quot; : &quot;2022-07-18T22:00:54Z&quot;,
&quot;_links&quot; : {
&quot;next&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;previous&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;results&quot; : [ {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.thousandeyes.com:80&quot;,
&quot;availableBandwidth&quot; : 9.100464,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;packetsBySecond&quot; : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ],
&quot;avgLatency&quot; : 167.04,
&quot;bandwidth&quot; : 4.3313155,
&quot;minLatency&quot; : 167,
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;maxLatency&quot; : 168,
&quot;proxyJitter&quot; : 1.2,
&quot;proxyAverageLatency&quot; : 45,
&quot;proxyLoss&quot; : 2.5,
&quot;healthScore&quot; : 0.98,
&quot;capacity&quot; : 210.10854,
&quot;loss&quot; : 0,
&quot;proxyMinLatency&quot; : 40,
&quot;jitter&quot; : 0.076808,
&quot;serverIp&quot; : &quot;50.18.127.223&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;proxyMaxLatency&quot; : 50,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.thousandeyes.com:80&quot;,
&quot;availableBandwidth&quot; : 9.100464,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;packetsBySecond&quot; : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ],
&quot;avgLatency&quot; : 167.04,
&quot;bandwidth&quot; : 4.3313155,
&quot;minLatency&quot; : 167,
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;maxLatency&quot; : 168,
&quot;proxyJitter&quot; : 1.2,
&quot;proxyAverageLatency&quot; : 45,
&quot;proxyLoss&quot; : 2.5,
&quot;healthScore&quot; : 0.98,
&quot;capacity&quot; : 210.10854,
&quot;loss&quot; : 0,
&quot;proxyMinLatency&quot; : 40,
&quot;jitter&quot; : 0.076808,
&quot;serverIp&quot; : &quot;50.18.127.223&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;proxyMaxLatency&quot; : 50,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
} ],
&quot;startDate&quot; : &quot;2022-07-17T22:00:54Z&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_test_network_results_error_400(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 400)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_401(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 401)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_403(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 403)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_404(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 404)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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.get_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_429(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 429)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_500(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 500)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_network_results_error_502(self) -> None:
"""Integration test for get_test_network_results error path (HTTP 502)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.TestDirection()
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(502)
) as context:
self.api.get_test_network_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_network_results", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_happy_path(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results success path"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
response_body_json = """
{
&quot;test&quot; : {
&quot;_links&quot; : {
&quot;testResults&quot; : [ {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/network&quot;
}, {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis&quot;
} ],
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;liveShare&quot; : false,
&quot;savedEvent&quot; : true,
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;type&quot; : &quot;agent-to-server&quot;,
&quot;enabled&quot; : true,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;alertsEnabled&quot; : true,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;
},
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;results&quot; : [ {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.google.com:443&quot;,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;targetIsProxy&quot; : true,
&quot;sourcePrefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;sourceIp&quot; : &quot;196.40.106.237&quot;,
&quot;pathTraces&quot; : [ {
&quot;hops&quot; : [ {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
}, {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
} ],
&quot;pathId&quot; : &quot;4711301366345855606023718047703941305741293841502186803&quot;
}, {
&quot;hops&quot; : [ {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
}, {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
} ],
&quot;pathId&quot; : &quot;4711301366345855606023718047703941305741293841502186803&quot;
} ],
&quot;serverIp&quot; : &quot;172.217.170.68&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.google.com:443&quot;,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;targetIsProxy&quot; : true,
&quot;sourcePrefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;sourceIp&quot; : &quot;196.40.106.237&quot;,
&quot;pathTraces&quot; : [ {
&quot;hops&quot; : [ {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
}, {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
} ],
&quot;pathId&quot; : &quot;4711301366345855606023718047703941305741293841502186803&quot;
}, {
&quot;hops&quot; : [ {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
}, {
&quot;rdns&quot; : &quot;core-router1.cpt2.host-h.net&quot;,
&quot;prefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;responseTime&quot; : 1,
&quot;hop&quot; : 1,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;mpls&quot; : &quot;mpls&quot;,
&quot;location&quot; : &quot;Cape Town, South Africa&quot;,
&quot;network&quot; : &quot;HETZNER (Pty) Ltd (AS 37153)&quot;
} ],
&quot;pathId&quot; : &quot;4711301366345855606023718047703941305741293841502186803&quot;
} ],
&quot;serverIp&quot; : &quot;172.217.170.68&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_test_path_vis_agent_round_results_error_400(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 400)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_401(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 401)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_403(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 403)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_404(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 404)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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.get_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_429(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 429)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_500(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 500)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_agent_round_results_error_502(self) -> None:
"""Integration test for get_test_path_vis_agent_round_results error path (HTTP 502)"""
test_id = '202701'
agent_id = '11'
round_id = '1384309800'
aid = '1234'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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(502)
) as context:
self.api.get_test_path_vis_agent_round_results(
test_id=test_id,
agent_id=agent_id,
round_id=round_id,
aid=aid,
direction=direction,
_headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_happy_path(self) -> None:
"""Integration test for get_test_path_vis_results success path"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
response_body_json = """
{
&quot;test&quot; : {
&quot;_links&quot; : {
&quot;testResults&quot; : [ {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/network&quot;
}, {
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis&quot;
} ],
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;liveShare&quot; : false,
&quot;savedEvent&quot; : true,
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;type&quot; : &quot;agent-to-server&quot;,
&quot;enabled&quot; : true,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;alertsEnabled&quot; : true,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;
},
&quot;endDate&quot; : &quot;2022-07-18T22:00:54Z&quot;,
&quot;_links&quot; : {
&quot;next&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;previous&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;results&quot; : [ {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.google.com:443&quot;,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;targetIsProxy&quot; : true,
&quot;sourcePrefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;sourceIp&quot; : &quot;196.40.106.237&quot;,
&quot;pathTraces&quot; : [ {
&quot;numberOfHops&quot; : 15,
&quot;responseTime&quot; : 1500,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;pathMtu&quot; : 1500,
&quot;pathId&quot; : &quot;1230899668701775614109128428722974545787322404682781961521&quot;,
&quot;mss&quot; : 1460
}, {
&quot;numberOfHops&quot; : 15,
&quot;responseTime&quot; : 1500,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;pathMtu&quot; : 1500,
&quot;pathId&quot; : &quot;1230899668701775614109128428722974545787322404682781961521&quot;,
&quot;mss&quot; : 1460
} ],
&quot;serverIp&quot; : &quot;172.217.170.68&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;date&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;server&quot; : &quot;www.google.com:443&quot;,
&quot;agent&quot; : {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;countryId&quot; : &quot;US&quot;
},
&quot;_links&quot; : {
&quot;appLink&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;targetIsProxy&quot; : true,
&quot;sourcePrefix&quot; : &quot;196.40.96.0/20&quot;,
&quot;sourceIp&quot; : &quot;196.40.106.237&quot;,
&quot;pathTraces&quot; : [ {
&quot;numberOfHops&quot; : 15,
&quot;responseTime&quot; : 1500,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;pathMtu&quot; : 1500,
&quot;pathId&quot; : &quot;1230899668701775614109128428722974545787322404682781961521&quot;,
&quot;mss&quot; : 1460
}, {
&quot;numberOfHops&quot; : 15,
&quot;responseTime&quot; : 1500,
&quot;ipAddress&quot; : &quot;196.40.106.237&quot;,
&quot;pathMtu&quot; : 1500,
&quot;pathId&quot; : &quot;1230899668701775614109128428722974545787322404682781961521&quot;,
&quot;mss&quot; : 1460
} ],
&quot;serverIp&quot; : &quot;172.217.170.68&quot;,
&quot;startTime&quot; : 1384309800,
&quot;endTime&quot; : 1384309800,
&quot;roundId&quot; : 1384309800,
&quot;direction&quot; : &quot;to-target&quot;
} ],
&quot;startDate&quot; : &quot;2022-07-17T22:00:54Z&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_test_path_vis_results_error_400(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 400)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_401(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 401)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_403(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 403)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_404(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 404)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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.get_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_429(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 429)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_500(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 500)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_test_path_vis_results_error_502(self) -> None:
"""Integration test for get_test_path_vis_results error path (HTTP 502)"""
test_id = '202701'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
cursor = 'cursor_example'
direction = thousandeyes_sdk.test_results.PathVisDirection()
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(502)
) as context:
self.api.get_test_path_vis_results(
test_id=test_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
cursor=cursor,
direction=direction,
_headers=self.te_headers("get_test_path_vis_results", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()