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

1185 lines
50 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.tests_assignment_on_agents_api import TestsAssignmentOnAgentsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestTestsAssignmentOnAgentsApiIntegration(IntegrationTestBase):
"""TestsAssignmentOnAgentsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = TestsAssignmentOnAgentsApi(self.api_client)
def test_assign_tests_happy_path(self) -> None:
"""Integration test for assign_tests success path"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
aid = '1234'
response_body_json = """
{
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;cloud&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;prefix&quot; : &quot;99.128.0.0/11&quot;,
&quot;coordinates&quot; : {
&quot;latitude&quot; : 37.77493,
&quot;longitude&quot; : -122.41942
},
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;networkProviderInfo&quot; : {
&quot;asn&quot; : 7018,
&quot;name&quot; : &quot;AT&amp;T Services, Inc.&quot;,
&quot;type&quot; : &quot;isp&quot;
},
&quot;countryId&quot; : &quot;US&quot;,
&quot;enabled&quot; : true,
&quot;network&quot; : &quot;AT&amp;T Services, Inc. (AS 7018)&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
}, {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
} ],
&quot;tags&quot; : [ {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
}, {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
} ],
&quot;tests&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;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;publicIpAddresses&quot; : [ &quot;192.168.1.78&quot;, &quot;f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c&quot; ],
&quot;ipAddresses&quot; : [ &quot;99.139.65.220&quot;, &quot;9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce&quot; ],
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;verifySslCertificates&quot; : true
}
"""
expected_response = json.loads(response_body_json)
response = self.api.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_assign_tests_error_400(self) -> None:
"""Integration test for assign_tests error path (HTTP 400)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_401(self) -> None:
"""Integration test for assign_tests error path (HTTP 401)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_403(self) -> None:
"""Integration test for assign_tests error path (HTTP 403)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_404(self) -> None:
"""Integration test for assign_tests error path (HTTP 404)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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(404)
) as context:
self.api.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_429(self) -> None:
"""Integration test for assign_tests error path (HTTP 429)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_500(self) -> None:
"""Integration test for assign_tests error path (HTTP 500)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_tests_error_502(self) -> None:
"""Integration test for assign_tests error path (HTTP 502)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.assign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("assign_tests", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_happy_path(self) -> None:
"""Integration test for overwrite_tests success path"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
aid = '1234'
response_body_json = """
{
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;cloud&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;prefix&quot; : &quot;99.128.0.0/11&quot;,
&quot;coordinates&quot; : {
&quot;latitude&quot; : 37.77493,
&quot;longitude&quot; : -122.41942
},
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;networkProviderInfo&quot; : {
&quot;asn&quot; : 7018,
&quot;name&quot; : &quot;AT&amp;T Services, Inc.&quot;,
&quot;type&quot; : &quot;isp&quot;
},
&quot;countryId&quot; : &quot;US&quot;,
&quot;enabled&quot; : true,
&quot;network&quot; : &quot;AT&amp;T Services, Inc. (AS 7018)&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
}, {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
} ],
&quot;tags&quot; : [ {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
}, {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
} ],
&quot;tests&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;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;publicIpAddresses&quot; : [ &quot;192.168.1.78&quot;, &quot;f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c&quot; ],
&quot;ipAddresses&quot; : [ &quot;99.139.65.220&quot;, &quot;9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce&quot; ],
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;verifySslCertificates&quot; : true
}
"""
expected_response = json.loads(response_body_json)
response = self.api.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_overwrite_tests_error_400(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 400)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_401(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 401)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_403(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 403)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_404(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 404)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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(404)
) as context:
self.api.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_429(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 429)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_500(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 500)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_overwrite_tests_error_502(self) -> None:
"""Integration test for overwrite_tests error path (HTTP 502)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.overwrite_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("overwrite_tests", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_happy_path(self) -> None:
"""Integration test for unassign_tests success path"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
aid = '1234'
response_body_json = """
{
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;cloud&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;prefix&quot; : &quot;99.128.0.0/11&quot;,
&quot;coordinates&quot; : {
&quot;latitude&quot; : 37.77493,
&quot;longitude&quot; : -122.41942
},
&quot;agentName&quot; : &quot;thousandeyes-stg-va-254&quot;,
&quot;networkProviderInfo&quot; : {
&quot;asn&quot; : 7018,
&quot;name&quot; : &quot;AT&amp;T Services, Inc.&quot;,
&quot;type&quot; : &quot;isp&quot;
},
&quot;countryId&quot; : &quot;US&quot;,
&quot;enabled&quot; : true,
&quot;network&quot; : &quot;AT&amp;T Services, Inc. (AS 7018)&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
}, {
&quot;labelId&quot; : &quot;11&quot;,
&quot;name&quot; : &quot;Label name&quot;
} ],
&quot;tags&quot; : [ {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
}, {
&quot;id&quot; : &quot;5aeab5d5-0d34-4d44-a7ac-fb440185295c&quot;,
&quot;value&quot; : &quot;San Francisco&quot;,
&quot;key&quot; : &quot;Location&quot;
} ],
&quot;tests&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;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;publicIpAddresses&quot; : [ &quot;192.168.1.78&quot;, &quot;f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c&quot; ],
&quot;ipAddresses&quot; : [ &quot;99.139.65.220&quot;, &quot;9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce&quot; ],
&quot;location&quot; : &quot;San Francisco Bay Area&quot;,
&quot;verifySslCertificates&quot; : true
}
"""
expected_response = json.loads(response_body_json)
response = self.api.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_unassign_tests_error_400(self) -> None:
"""Integration test for unassign_tests error path (HTTP 400)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_401(self) -> None:
"""Integration test for unassign_tests error path (HTTP 401)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_403(self) -> None:
"""Integration test for unassign_tests error path (HTTP 403)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_404(self) -> None:
"""Integration test for unassign_tests error path (HTTP 404)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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(404)
) as context:
self.api.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_429(self) -> None:
"""Integration test for unassign_tests error path (HTTP 429)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_500(self) -> None:
"""Integration test for unassign_tests error path (HTTP 500)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_tests_error_502(self) -> None:
"""Integration test for unassign_tests error path (HTTP 502)"""
request_body_json = """
{
"testIds" : [ "281474976710706" ]
}
"""
agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json)
agent_id = '281474976710706'
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.unassign_tests(
agent_id=agent_id,
agent_tests_assign_request=agent_tests_assign_request,
aid=aid,
_headers=self.te_headers("unassign_tests", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()