thousandeyes-sdk-python/thousandeyes-sdk-tests/test/test_api_tests_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

4681 lines
215 KiB
Python

# coding: utf-8
"""
Tests API
**Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests.
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.tests.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.tests.api.api_tests_api import APITestsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestAPITestsApiIntegration(IntegrationTestBase):
"""APITestsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = APITestsApi(self.api_client)
def test_create_api_test_happy_path(self) -> None:
"""Integration test for create_api_test success path"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
response_body_json = """
{
&quot;clientCertificate&quot; : &quot;-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n&quot;,
&quot;mtuMeasurements&quot; : false,
&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;credentials&quot; : [ &quot;3247&quot;, &quot;1051&quot; ],
&quot;alertRules&quot; : [ {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
} ],
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;probeMode&quot; : &quot;auto&quot;,
&quot;requests&quot; : [ {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
}, {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
} ],
&quot;type&quot; : &quot;api&quot;,
&quot;usePublicBgp&quot; : true,
&quot;enabled&quot; : true,
&quot;vaultCredentials&quot; : [ {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
}, {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
} ],
&quot;protocol&quot; : &quot;tcp&quot;,
&quot;collectProxyNetworkData&quot; : false,
&quot;followRedirects&quot; : true,
&quot;pathTraceMode&quot; : &quot;classic&quot;,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;alertsEnabled&quot; : true,
&quot;clientCertDomainsAllowList&quot; : &quot;www.thousandeyes.com&quot;,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;,
&quot;numPathTraces&quot; : 3,
&quot;bgpMeasurements&quot; : true,
&quot;overrideAgentProxy&quot; : false,
&quot;predefinedVariables&quot; : [ {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
}, {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
} ],
&quot;liveShare&quot; : false,
&quot;distributedTracing&quot; : false,
&quot;savedEvent&quot; : true,
&quot;networkMeasurements&quot; : true,
&quot;url&quot; : &quot;www.thousandeyes.com&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
}, {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
} ],
&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;agents&quot; : [ {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
}, {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
} ],
&quot;timeLimit&quot; : 19,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;randomizedStartTime&quot; : false,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;sharedWithAccounts&quot; : [ {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
} ],
&quot;overrideProxyId&quot; : &quot;281474976710706&quot;,
&quot;sslVersionId&quot; : &quot;0&quot;,
&quot;targetTime&quot; : 1,
&quot;monitors&quot; : [ {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
}, {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_create_api_test_error_400(self) -> None:
"""Integration test for create_api_test error path (HTTP 400)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_401(self) -> None:
"""Integration test for create_api_test error path (HTTP 401)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_403(self) -> None:
"""Integration test for create_api_test error path (HTTP 403)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_404(self) -> None:
"""Integration test for create_api_test error path (HTTP 404)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_429(self) -> None:
"""Integration test for create_api_test error path (HTTP 429)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_500(self) -> None:
"""Integration test for create_api_test error path (HTTP 500)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_api_test_error_502(self) -> None:
"""Integration test for create_api_test error path (HTTP 502)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.create_api_test(
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("create_api_test", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_happy_path(self) -> None:
"""Integration test for delete_api_test success path"""
test_id = '202701'
aid = '1234'
response = self.api.delete_api_test_with_http_info(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test"),
)
self.assertEqual(204, response.status_code)
self.assertIsNone(response.data)
def test_delete_api_test_error_401(self) -> None:
"""Integration test for delete_api_test error path (HTTP 401)"""
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_error_403(self) -> None:
"""Integration test for delete_api_test error path (HTTP 403)"""
test_id = '202701'
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_error_404(self) -> None:
"""Integration test for delete_api_test error path (HTTP 404)"""
test_id = '202701'
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_error_429(self) -> None:
"""Integration test for delete_api_test error path (HTTP 429)"""
test_id = '202701'
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_error_500(self) -> None:
"""Integration test for delete_api_test error path (HTTP 500)"""
test_id = '202701'
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_api_test_error_502(self) -> None:
"""Integration test for delete_api_test error path (HTTP 502)"""
test_id = '202701'
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.delete_api_test(
test_id=test_id,
aid=aid,
_headers=self.te_headers("delete_api_test", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_happy_path(self) -> None:
"""Integration test for get_api_test success path"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
response_body_json = """
{
&quot;clientCertificate&quot; : &quot;-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n&quot;,
&quot;mtuMeasurements&quot; : false,
&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;credentials&quot; : [ &quot;3247&quot;, &quot;1051&quot; ],
&quot;alertRules&quot; : [ {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
} ],
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;probeMode&quot; : &quot;auto&quot;,
&quot;requests&quot; : [ {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
}, {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
} ],
&quot;type&quot; : &quot;api&quot;,
&quot;usePublicBgp&quot; : true,
&quot;enabled&quot; : true,
&quot;vaultCredentials&quot; : [ {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
}, {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
} ],
&quot;protocol&quot; : &quot;tcp&quot;,
&quot;collectProxyNetworkData&quot; : false,
&quot;followRedirects&quot; : true,
&quot;pathTraceMode&quot; : &quot;classic&quot;,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;alertsEnabled&quot; : true,
&quot;clientCertDomainsAllowList&quot; : &quot;www.thousandeyes.com&quot;,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;,
&quot;numPathTraces&quot; : 3,
&quot;bgpMeasurements&quot; : true,
&quot;overrideAgentProxy&quot; : false,
&quot;predefinedVariables&quot; : [ {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
}, {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
} ],
&quot;liveShare&quot; : false,
&quot;distributedTracing&quot; : false,
&quot;savedEvent&quot; : true,
&quot;networkMeasurements&quot; : true,
&quot;url&quot; : &quot;www.thousandeyes.com&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
}, {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
} ],
&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;agents&quot; : [ {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
}, {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
} ],
&quot;timeLimit&quot; : 19,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;randomizedStartTime&quot; : false,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;sharedWithAccounts&quot; : [ {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
} ],
&quot;overrideProxyId&quot; : &quot;281474976710706&quot;,
&quot;sslVersionId&quot; : &quot;0&quot;,
&quot;targetTime&quot; : 1,
&quot;monitors&quot; : [ {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
}, {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_api_test_error_401(self) -> None:
"""Integration test for get_api_test error path (HTTP 401)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_error_403(self) -> None:
"""Integration test for get_api_test error path (HTTP 403)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_error_404(self) -> None:
"""Integration test for get_api_test error path (HTTP 404)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_error_429(self) -> None:
"""Integration test for get_api_test error path (HTTP 429)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_error_500(self) -> None:
"""Integration test for get_api_test error path (HTTP 500)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_test_error_502(self) -> None:
"""Integration test for get_api_test error path (HTTP 502)"""
test_id = '202701'
aid = '1234'
version_id = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.get_api_test(
test_id=test_id,
aid=aid,
version_id=version_id,
expand=expand,
_headers=self.te_headers("get_api_test", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_happy_path(self) -> None:
"""Integration test for get_api_tests success path"""
aid = '1234'
response_body_json = """
{
&quot;tests&quot; : [ {
&quot;clientCertificate&quot; : &quot;-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n&quot;,
&quot;mtuMeasurements&quot; : false,
&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;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;probeMode&quot; : &quot;auto&quot;,
&quot;requests&quot; : [ {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
}, {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
} ],
&quot;type&quot; : &quot;api&quot;,
&quot;usePublicBgp&quot; : true,
&quot;enabled&quot; : true,
&quot;protocol&quot; : &quot;tcp&quot;,
&quot;collectProxyNetworkData&quot; : false,
&quot;followRedirects&quot; : true,
&quot;pathTraceMode&quot; : &quot;classic&quot;,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;alertsEnabled&quot; : true,
&quot;clientCertDomainsAllowList&quot; : &quot;www.thousandeyes.com&quot;,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;,
&quot;numPathTraces&quot; : 3,
&quot;bgpMeasurements&quot; : true,
&quot;overrideAgentProxy&quot; : false,
&quot;predefinedVariables&quot; : [ {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
}, {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
} ],
&quot;liveShare&quot; : false,
&quot;distributedTracing&quot; : false,
&quot;savedEvent&quot; : true,
&quot;networkMeasurements&quot; : true,
&quot;url&quot; : &quot;www.thousandeyes.com&quot;,
&quot;timeLimit&quot; : 19,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;randomizedStartTime&quot; : false,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;overrideProxyId&quot; : &quot;281474976710706&quot;,
&quot;sslVersionId&quot; : &quot;0&quot;,
&quot;targetTime&quot; : 1
}, {
&quot;clientCertificate&quot; : &quot;-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n&quot;,
&quot;mtuMeasurements&quot; : false,
&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;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;probeMode&quot; : &quot;auto&quot;,
&quot;requests&quot; : [ {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
}, {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
} ],
&quot;type&quot; : &quot;api&quot;,
&quot;usePublicBgp&quot; : true,
&quot;enabled&quot; : true,
&quot;protocol&quot; : &quot;tcp&quot;,
&quot;collectProxyNetworkData&quot; : false,
&quot;followRedirects&quot; : true,
&quot;pathTraceMode&quot; : &quot;classic&quot;,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;alertsEnabled&quot; : true,
&quot;clientCertDomainsAllowList&quot; : &quot;www.thousandeyes.com&quot;,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;,
&quot;numPathTraces&quot; : 3,
&quot;bgpMeasurements&quot; : true,
&quot;overrideAgentProxy&quot; : false,
&quot;predefinedVariables&quot; : [ {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
}, {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
} ],
&quot;liveShare&quot; : false,
&quot;distributedTracing&quot; : false,
&quot;savedEvent&quot; : true,
&quot;networkMeasurements&quot; : true,
&quot;url&quot; : &quot;www.thousandeyes.com&quot;,
&quot;timeLimit&quot; : 19,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;randomizedStartTime&quot; : false,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;overrideProxyId&quot; : &quot;281474976710706&quot;,
&quot;sslVersionId&quot; : &quot;0&quot;,
&quot;targetTime&quot; : 1
} ],
&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;
}
}
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_api_tests_error_401(self) -> None:
"""Integration test for get_api_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_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_error_403(self) -> None:
"""Integration test for get_api_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_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_error_404(self) -> None:
"""Integration test for get_api_tests 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_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_error_429(self) -> None:
"""Integration test for get_api_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_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_error_500(self) -> None:
"""Integration test for get_api_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_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_api_tests_error_502(self) -> None:
"""Integration test for get_api_tests error path (HTTP 502)"""
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.get_api_tests(
aid=aid,
_headers=self.te_headers("get_api_tests", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_happy_path(self) -> None:
"""Integration test for update_api_test success path"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
response_body_json = """
{
&quot;clientCertificate&quot; : &quot;-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n&quot;,
&quot;mtuMeasurements&quot; : false,
&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;credentials&quot; : [ &quot;3247&quot;, &quot;1051&quot; ],
&quot;alertRules&quot; : [ {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
}, {
&quot;severity&quot; : &quot;major&quot;,
&quot;expression&quot; : &quot;((hops((hopDelay &gt;&#x3D; 100 ms))))&quot;,
&quot;alertType&quot; : &quot;http-server&quot;,
&quot;roundsViolatingMode&quot; : &quot;exact&quot;,
&quot;sensitivityLevel&quot; : &quot;medium&quot;,
&quot;roundsViolatingOutOf&quot; : 5,
&quot;roundsViolatingRequired&quot; : 2,
&quot;isDefault&quot; : true,
&quot;minimumSourcesPct&quot; : 99,
&quot;ruleName&quot; : &quot;The End of the Internet&quot;,
&quot;minimumSources&quot; : 10,
&quot;ruleId&quot; : &quot;127094&quot;,
&quot;direction&quot; : &quot;to-target&quot;
} ],
&quot;description&quot; : &quot;ThousandEyes Test&quot;,
&quot;probeMode&quot; : &quot;auto&quot;,
&quot;requests&quot; : [ {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
}, {
&quot;headers&quot; : [ {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
}, {
&quot;value&quot; : &quot;keep-alive&quot;,
&quot;key&quot; : &quot;x-custom-header&quot;
} ],
&quot;variables&quot; : [ {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
}, {
&quot;name&quot; : &quot;myTestName&quot;,
&quot;value&quot; : &quot;tests[0].name&quot;
} ],
&quot;clientId&quot; : &quot;client-id&quot;,
&quot;tokenUrl&quot; : &quot;https://id.cisco.com/oauth2/default/v1/token&quot;,
&quot;method&quot; : &quot;get&quot;,
&quot;verifyCertificate&quot; : false,
&quot;body&quot; : &quot;body&quot;,
&quot;url&quot; : &quot;https://api.thousandeyes.com/v7/status&quot;,
&quot;password&quot; : &quot;basic_pw123&quot;,
&quot;bearerToken&quot; : &quot;abcd-1234-...&quot;,
&quot;scope&quot; : &quot;read, write, deploy&quot;,
&quot;name&quot; : &quot;Step 1&quot;,
&quot;waitTimeMs&quot; : 0,
&quot;clientAuthentication&quot; : &quot;basic-auth-header&quot;,
&quot;clientSecret&quot; : &quot;client-secret&quot;,
&quot;assertions&quot; : [ {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
}, {
&quot;name&quot; : &quot;status-code&quot;,
&quot;value&quot; : &quot;200&quot;,
&quot;operator&quot; : &quot;is&quot;
} ],
&quot;authType&quot; : &quot;none&quot;,
&quot;collectApiResponse&quot; : true,
&quot;username&quot; : &quot;ThousandEyesUserName&quot;
} ],
&quot;type&quot; : &quot;api&quot;,
&quot;usePublicBgp&quot; : true,
&quot;enabled&quot; : true,
&quot;vaultCredentials&quot; : [ {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
}, {
&quot;secretId&quot; : &quot;f27e85b2-318b-4145-b5aa-c9dc8d8b0819&quot;,
&quot;target&quot; : &quot;username&quot;
} ],
&quot;protocol&quot; : &quot;tcp&quot;,
&quot;collectProxyNetworkData&quot; : false,
&quot;followRedirects&quot; : true,
&quot;pathTraceMode&quot; : &quot;classic&quot;,
&quot;modifiedBy&quot; : &quot;user@user.com&quot;,
&quot;alertsEnabled&quot; : true,
&quot;clientCertDomainsAllowList&quot; : &quot;www.thousandeyes.com&quot;,
&quot;testName&quot; : &quot;ThousandEyes Test&quot;,
&quot;numPathTraces&quot; : 3,
&quot;bgpMeasurements&quot; : true,
&quot;overrideAgentProxy&quot; : false,
&quot;predefinedVariables&quot; : [ {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
}, {
&quot;name&quot; : &quot;myUsername&quot;,
&quot;value&quot; : &quot;ThousandEyesAccountUserName&quot;
} ],
&quot;liveShare&quot; : false,
&quot;distributedTracing&quot; : false,
&quot;savedEvent&quot; : true,
&quot;networkMeasurements&quot; : true,
&quot;url&quot; : &quot;www.thousandeyes.com&quot;,
&quot;labels&quot; : [ {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
}, {
&quot;labelId&quot; : &quot;961&quot;,
&quot;name&quot; : &quot;Artem label&quot;,
&quot;isBuiltin&quot; : false
} ],
&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;agents&quot; : [ {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
}, {
&quot;agentId&quot; : &quot;281474976710706&quot;,
&quot;agentType&quot; : &quot;enterprise-cluster&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;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
} ],
&quot;timeLimit&quot; : 19,
&quot;createdDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;createdBy&quot; : &quot;user@user.com&quot;,
&quot;randomizedStartTime&quot; : false,
&quot;modifiedDate&quot; : &quot;2022-07-17T22:00:54Z&quot;,
&quot;interval&quot; : 60,
&quot;testId&quot; : &quot;281474976710706&quot;,
&quot;sharedWithAccounts&quot; : [ {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;name&quot; : &quot;Account name&quot;,
&quot;aid&quot; : &quot;1234&quot;
} ],
&quot;overrideProxyId&quot; : &quot;281474976710706&quot;,
&quot;sslVersionId&quot; : &quot;0&quot;,
&quot;targetTime&quot; : 1,
&quot;monitors&quot; : [ {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
}, {
&quot;monitorType&quot; : &quot;public&quot;,
&quot;monitorId&quot; : &quot;1234&quot;,
&quot;monitorName&quot; : &quot;Seattle, WA&quot;,
&quot;ipAddress&quot; : &quot;4.69.184.193&quot;,
&quot;countryId&quot; : &quot;GB&quot;,
&quot;network&quot; : &quot;Level 3 Communications, Inc. (AS 3356)&quot;
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_update_api_test_error_400(self) -> None:
"""Integration test for update_api_test error path (HTTP 400)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_401(self) -> None:
"""Integration test for update_api_test error path (HTTP 401)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_403(self) -> None:
"""Integration test for update_api_test error path (HTTP 403)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_404(self) -> None:
"""Integration test for update_api_test error path (HTTP 404)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_429(self) -> None:
"""Integration test for update_api_test error path (HTTP 429)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_500(self) -> None:
"""Integration test for update_api_test error path (HTTP 500)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_api_test_error_502(self) -> None:
"""Integration test for update_api_test error path (HTTP 502)"""
request_body_json = """
{
"clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n",
"mtuMeasurements" : false,
"_links" : {
"testResults" : [ {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network"
}, {
"href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis"
} ],
"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"
}
},
"credentials" : [ "3247", "1051" ],
"alertRules" : [ "344753", "212697" ],
"description" : "ThousandEyes Test",
"probeMode" : "auto",
"requests" : [ {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
}, {
"headers" : [ {
"value" : "keep-alive",
"key" : "x-custom-header"
}, {
"value" : "keep-alive",
"key" : "x-custom-header"
} ],
"variables" : [ {
"name" : "myTestName",
"value" : "tests[0].name"
}, {
"name" : "myTestName",
"value" : "tests[0].name"
} ],
"clientId" : "client-id",
"tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token",
"method" : "get",
"verifyCertificate" : false,
"body" : "body",
"url" : "https://api.thousandeyes.com/v7/status",
"password" : "basic_pw123",
"bearerToken" : "abcd-1234-...",
"scope" : "read, write, deploy",
"name" : "Step 1",
"waitTimeMs" : 0,
"clientAuthentication" : "basic-auth-header",
"clientSecret" : "client-secret",
"assertions" : [ {
"name" : "status-code",
"value" : "200",
"operator" : "is"
}, {
"name" : "status-code",
"value" : "200",
"operator" : "is"
} ],
"authType" : "none",
"collectApiResponse" : true,
"username" : "ThousandEyesUserName"
} ],
"type" : "api",
"usePublicBgp" : true,
"enabled" : true,
"vaultCredentials" : [ {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
}, {
"secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819",
"target" : "username"
} ],
"protocol" : "tcp",
"collectProxyNetworkData" : false,
"followRedirects" : true,
"pathTraceMode" : "classic",
"modifiedBy" : "user@user.com",
"alertsEnabled" : true,
"clientCertDomainsAllowList" : "www.thousandeyes.com",
"testName" : "ThousandEyes Test",
"numPathTraces" : 3,
"bgpMeasurements" : true,
"overrideAgentProxy" : false,
"predefinedVariables" : [ {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
}, {
"name" : "myUsername",
"value" : "ThousandEyesAccountUserName"
} ],
"liveShare" : false,
"distributedTracing" : false,
"savedEvent" : true,
"networkMeasurements" : true,
"url" : "www.thousandeyes.com",
"labels" : [ "9842", "1283" ],
"tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ],
"agents" : [ {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
}, {
"agentId" : "125",
"sourceIpAddress" : "1.1.1.1"
} ],
"timeLimit" : 19,
"createdDate" : "2022-07-17T22:00:54Z",
"createdBy" : "user@user.com",
"randomizedStartTime" : false,
"modifiedDate" : "2022-07-17T22:00:54Z",
"interval" : 60,
"testId" : "281474976710706",
"sharedWithAccounts" : [ "1234", "12345" ],
"overrideProxyId" : "281474976710706",
"sslVersionId" : "0",
"targetTime" : 1,
"monitors" : [ "17410", "5" ]
}
"""
api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json)
test_id = '202701'
aid = '1234'
expand = [thousandeyes_sdk.tests.ExpandTestOptions()]
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.update_api_test(
test_id=test_id,
api_test_request=api_test_request,
aid=aid,
expand=expand,
_headers=self.te_headers("update_api_test", error_status="502"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()