thousandeyes-sdk-python/thousandeyes-sdk-snapshots/test/test_test_snapshots_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

396 lines
15 KiB
Python

# coding: utf-8
"""
Test Snapshots API
Creates a new test snapshot 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.snapshots.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.snapshots.api.test_snapshots_api import TestSnapshotsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestTestSnapshotsApiIntegration(IntegrationTestBase):
"""TestSnapshotsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = TestSnapshotsApi(self.api_client)
def test_create_test_snapshot_happy_path(self) -> None:
"""Integration test for create_test_snapshot success path"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
response_body_json = """
{
&quot;shareDate&quot; : &quot;2023-06-06T00:00:00Z&quot;,
&quot;uid&quot; : &quot;281474976810911&quot;,
&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;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;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;startRoundId&quot; : 1538784000,
&quot;displayName&quot; : &quot;Snapshot created through API&quot;,
&quot;endRoundId&quot; : 1538787600,
&quot;testId&quot; : &quot;281474976710801&quot;,
&quot;extraParams&quot; : &quot;params&quot;,
&quot;id&quot; : &quot;wdiac&quot;,
&quot;roundId&quot; : 1538784000,
&quot;sourceTestId&quot; : &quot;281474976710706&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_create_test_snapshot_error_400(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 400)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_401(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 401)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_403(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 403)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_404(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 404)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_429(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 429)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_500(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 500)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_test_snapshot_error_502(self) -> None:
"""Integration test for create_test_snapshot error path (HTTP 502)"""
request_body_json = """
{
"endDate" : "2023-06-06T01:00:00Z",
"displayName" : "Snapshot created through API",
"isPublic" : false,
"startDate" : "2023-06-06T00:00:00Z"
}
"""
snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
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.create_test_snapshot(
test_id=test_id,
snapshot_request=snapshot_request,
aid=aid,
_headers=self.te_headers("create_test_snapshot", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()