thousandeyes-sdk-python/thousandeyes-sdk-bgp-monitors/test/test_bgp_monitors_api_integration.py
2026-08-03 16:04:35 +00:00

204 lines
7.4 KiB
Python

# coding: utf-8
"""
BGP Monitors API
**Note:** Private monitor data is not available for ThousandEyes for Government instance. Retrieve information about BGP monitors available to your ThousandEyes account. ThousandEyes ingests BGP routing data from dozens of global BGP collectors and automatically integrates that visibility as a configurable layer under service, network, and path visualization layers. When you specify a service URL in a test, layered BGP tests automatically track reachability and path changes for any relevant prefix. When you use an IP address as the target for a test, the ThousandEyes platform monitors the relevant internet-routed prefix. You can also create specific BGP monitoring for a prefix, and can alert on hijacks and leaks. For more information about monitors, see [Inside-Out BGP Visibility](https://docs.thousandeyes.com/product-documentation/internet-and-wan-monitoring/tests/bgp-tests/inside-out-bgp-visibility).
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.bgp_monitors.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.bgp_monitors.api.bgp_monitors_api import BGPMonitorsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestBGPMonitorsApiIntegration(IntegrationTestBase):
"""BGPMonitorsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = BGPMonitorsApi(self.api_client)
def test_get_bgp_monitors_happy_path(self) -> None:
"""Integration test for get_bgp_monitors 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"
}
},
"monitors" : [ {
"monitorType" : "public",
"monitorId" : "1234",
"monitorName" : "Seattle, WA",
"ipAddress" : "4.69.184.193",
"countryId" : "GB",
"network" : "Level 3 Communications, Inc. (AS 3356)"
}, {
"monitorType" : "public",
"monitorId" : "1234",
"monitorName" : "Seattle, WA",
"ipAddress" : "4.69.184.193",
"countryId" : "GB",
"network" : "Level 3 Communications, Inc. (AS 3356)"
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_bgp_monitors_error_401(self) -> None:
"""Integration test for get_bgp_monitors 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_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_bgp_monitors_error_403(self) -> None:
"""Integration test for get_bgp_monitors 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_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_bgp_monitors_error_404(self) -> None:
"""Integration test for get_bgp_monitors error path (HTTP 404)"""
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.get_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_bgp_monitors_error_429(self) -> None:
"""Integration test for get_bgp_monitors 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_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_bgp_monitors_error_500(self) -> None:
"""Integration test for get_bgp_monitors 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_bgp_monitors(
aid=aid,
_headers=self.te_headers("get_bgp_monitors", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()