thousandeyes-sdk-python/thousandeyes-sdk-endpoint-tests/test/test_endpoint_real_user_tests_api_integration.py
2026-08-03 16:04:35 +00:00

177 lines
6.2 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_real_user_tests_api import EndpointRealUserTestsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestEndpointRealUserTestsApiIntegration(IntegrationTestBase):
"""EndpointRealUserTestsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = EndpointRealUserTestsApi(self.api_client)
def test_get_endpoint_real_user_tests_happy_path(self) -> None:
"""Integration test for get_endpoint_real_user_tests success path"""
aid = '1234'
response_body_json = """
{
"realUserTests" : [ {
"includedDomains" : [ "example.com", "example.com" ],
"profileId" : "73421",
"monitoringSettings" : {
"monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9",
"monitoringSettingsType" : "agent-tags",
"tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ],
"labelIds" : [ "567" ]
},
"name" : "Corporate domains",
"excludedDomains" : [ "static.example.com", "static.example.com" ],
"aid" : "1234"
}, {
"includedDomains" : [ "example.com", "example.com" ],
"profileId" : "73421",
"monitoringSettings" : {
"monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9",
"monitoringSettingsType" : "agent-tags",
"tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ],
"labelIds" : [ "567" ]
},
"name" : "Corporate domains",
"excludedDomains" : [ "static.example.com", "static.example.com" ],
"aid" : "1234"
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_endpoint_real_user_tests(
aid=aid,
_headers=self.te_headers("get_endpoint_real_user_tests"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_endpoint_real_user_tests_error_401(self) -> None:
"""Integration test for get_endpoint_real_user_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_real_user_tests(
aid=aid,
_headers=self.te_headers("get_endpoint_real_user_tests", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_real_user_tests_error_403(self) -> None:
"""Integration test for get_endpoint_real_user_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_real_user_tests(
aid=aid,
_headers=self.te_headers("get_endpoint_real_user_tests", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_real_user_tests_error_429(self) -> None:
"""Integration test for get_endpoint_real_user_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_real_user_tests(
aid=aid,
_headers=self.te_headers("get_endpoint_real_user_tests", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_endpoint_real_user_tests_error_500(self) -> None:
"""Integration test for get_endpoint_real_user_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_real_user_tests(
aid=aid,
_headers=self.te_headers("get_endpoint_real_user_tests", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()