mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2026-08-04 00:46:52 +00:00
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>
1525 lines
60 KiB
Python
1525 lines
60 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Integrations API
|
|
|
|
**Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations.
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import thousandeyes_sdk.connectors.models
|
|
|
|
from thousandeyes_sdk.core.exceptions import ApiException
|
|
from thousandeyes_sdk.connectors.api.generic_connectors_api import GenericConnectorsApi
|
|
from .integration_test_utils import IntegrationTestBase
|
|
from .test_utils import assert_constructed_model_matches_example_json
|
|
|
|
|
|
class TestGenericConnectorsApiIntegration(IntegrationTestBase):
|
|
"""GenericConnectorsApi integration test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.api = GenericConnectorsApi(self.api_client)
|
|
|
|
|
|
def test_create_generic_connector_happy_path(self) -> None:
|
|
"""Integration test for create_generic_connector success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.create_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_create_generic_connector_error_400(self) -> None:
|
|
"""Integration test for create_generic_connector error path (HTTP 400)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
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_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_generic_connector_error_401(self) -> None:
|
|
"""Integration test for create_generic_connector error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
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_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_generic_connector_error_403(self) -> None:
|
|
"""Integration test for create_generic_connector error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
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_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_generic_connector_error_404(self) -> None:
|
|
"""Integration test for create_generic_connector error path (HTTP 404)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
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_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_generic_connector_error_500(self) -> None:
|
|
"""Integration test for create_generic_connector error path (HTTP 500)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
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_generic_connector(
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("create_generic_connector", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_delete_generic_connector_happy_path(self) -> None:
|
|
"""Integration test for delete_generic_connector success path"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
aid = '1234'
|
|
response = self.api.delete_generic_connector_with_http_info(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector"),
|
|
)
|
|
self.assertEqual(204, response.status_code)
|
|
self.assertIsNone(response.data)
|
|
|
|
|
|
def test_delete_generic_connector_error_400(self) -> None:
|
|
"""Integration test for delete_generic_connector error path (HTTP 400)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.delete_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_generic_connector_error_401(self) -> None:
|
|
"""Integration test for delete_generic_connector error path (HTTP 401)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.delete_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_generic_connector_error_403(self) -> None:
|
|
"""Integration test for delete_generic_connector error path (HTTP 403)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.delete_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_generic_connector_error_404(self) -> None:
|
|
"""Integration test for delete_generic_connector error path (HTTP 404)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.delete_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_generic_connector_error_500(self) -> None:
|
|
"""Integration test for delete_generic_connector error path (HTTP 500)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.delete_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("delete_generic_connector", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_generic_connector_happy_path(self) -> None:
|
|
"""Integration test for get_generic_connector success path"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_generic_connector_error_400(self) -> None:
|
|
"""Integration test for get_generic_connector error path (HTTP 400)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.get_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connector_error_401(self) -> None:
|
|
"""Integration test for get_generic_connector error path (HTTP 401)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connector_error_403(self) -> None:
|
|
"""Integration test for get_generic_connector error path (HTTP 403)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.get_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connector_error_404(self) -> None:
|
|
"""Integration test for get_generic_connector error path (HTTP 404)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.get_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connector_error_500(self) -> None:
|
|
"""Integration test for get_generic_connector error path (HTTP 500)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.get_generic_connector(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connector", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_generic_connectors_happy_path(self) -> None:
|
|
"""Integration test for get_generic_connectors success path"""
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"_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"
|
|
}
|
|
},
|
|
"items" : [ {
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}, {
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_generic_connectors_error_400(self) -> None:
|
|
"""Integration test for get_generic_connectors error path (HTTP 400)"""
|
|
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.get_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connectors_error_401(self) -> None:
|
|
"""Integration test for get_generic_connectors 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_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connectors_error_403(self) -> None:
|
|
"""Integration test for get_generic_connectors error path (HTTP 403)"""
|
|
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.get_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connectors_error_404(self) -> None:
|
|
"""Integration test for get_generic_connectors error path (HTTP 404)"""
|
|
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.get_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_generic_connectors_error_500(self) -> None:
|
|
"""Integration test for get_generic_connectors error path (HTTP 500)"""
|
|
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.get_generic_connectors(
|
|
aid=aid,
|
|
_headers=self.te_headers("get_generic_connectors", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_list_generic_connector_operations_happy_path(self) -> None:
|
|
"""Integration test for list_generic_connector_operations success path"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"_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"
|
|
}
|
|
},
|
|
"items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_list_generic_connector_operations_error_400(self) -> None:
|
|
"""Integration test for list_generic_connector_operations error path (HTTP 400)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_list_generic_connector_operations_error_401(self) -> None:
|
|
"""Integration test for list_generic_connector_operations error path (HTTP 401)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_list_generic_connector_operations_error_403(self) -> None:
|
|
"""Integration test for list_generic_connector_operations error path (HTTP 403)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_list_generic_connector_operations_error_404(self) -> None:
|
|
"""Integration test for list_generic_connector_operations error path (HTTP 404)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_list_generic_connector_operations_error_500(self) -> None:
|
|
"""Integration test for list_generic_connector_operations error path (HTTP 500)"""
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.list_generic_connector_operations(
|
|
id=id,
|
|
aid=aid,
|
|
_headers=self.te_headers("list_generic_connector_operations", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_update_generic_connector_happy_path(self) -> None:
|
|
"""Integration test for update_generic_connector success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_update_generic_connector_error_400(self) -> None:
|
|
"""Integration test for update_generic_connector error path (HTTP 400)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_generic_connector_error_401(self) -> None:
|
|
"""Integration test for update_generic_connector error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_generic_connector_error_403(self) -> None:
|
|
"""Integration test for update_generic_connector error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_generic_connector_error_404(self) -> None:
|
|
"""Integration test for update_generic_connector error path (HTTP 404)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_generic_connector_error_500(self) -> None:
|
|
"""Integration test for update_generic_connector error path (HTTP 500)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"headers" : [ {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
}, {
|
|
"name" : "Content-Type",
|
|
"value" : "application/json"
|
|
} ],
|
|
"lastModifiedDate" : 1770293655756,
|
|
"_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"
|
|
}
|
|
},
|
|
"name" : "Cisco Slack",
|
|
"id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf",
|
|
"type" : "generic",
|
|
"target" : "https://hooks.slack.com/services/abc/xyz",
|
|
"authentication" : {
|
|
"password" : "abc123",
|
|
"type" : "basic",
|
|
"username" : "user1"
|
|
}
|
|
}
|
|
|
|
"""
|
|
generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json)
|
|
id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf'
|
|
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.update_generic_connector(
|
|
id=id,
|
|
generic_connector=generic_connector,
|
|
aid=aid,
|
|
_headers=self.te_headers("update_generic_connector", error_status="500"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|