# coding: utf-8 """ Administrative API Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. """ # noqa: E501 import json import unittest import thousandeyes_sdk.administrative.models from thousandeyes_sdk.core.exceptions import ApiException from thousandeyes_sdk.administrative.api.account_groups_api import AccountGroupsApi from .integration_test_utils import IntegrationTestBase from .test_utils import assert_constructed_model_matches_example_json class TestAccountGroupsApiIntegration(IntegrationTestBase): """AccountGroupsApi integration test stubs""" def setUp(self) -> None: super().setUp() self.api = AccountGroupsApi(self.api_client) def test_create_account_group_happy_path(self) -> None: """Integration test for create_account_group success path""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] response_body_json = """ { "isCurrentAccountGroup" : true, "organizationName" : "organizationName", "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "accountGroupName" : "Account A", "isDefaultAccountGroup" : true, "aid" : "1234", "orgId" : "12345", "users" : [ { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" }, { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" } ] } """ expected_response = json.loads(response_body_json) response = self.api.create_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group"), ) assert_constructed_model_matches_example_json(response, expected_response) def test_create_account_group_error_400(self) -> None: """Integration test for create_account_group error path (HTTP 400)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] 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_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="400"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_create_account_group_error_401(self) -> None: """Integration test for create_account_group error path (HTTP 401)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] 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_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="401"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_create_account_group_error_403(self) -> None: """Integration test for create_account_group error path (HTTP 403)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(403) ) as context: self.api.create_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="403"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_create_account_group_error_404(self) -> None: """Integration test for create_account_group error path (HTTP 404)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(404) ) as context: self.api.create_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="404"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_create_account_group_error_429(self) -> None: """Integration test for create_account_group error path (HTTP 429)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(429) ) as context: self.api.create_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="429"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_create_account_group_error_500(self) -> None: """Integration test for create_account_group error path (HTTP 500)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(500) ) as context: self.api.create_account_group( account_group_request=account_group_request, expand=expand, _headers=self.te_headers("create_account_group", error_status="500"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_happy_path(self) -> None: """Integration test for delete_account_group success path""" id = '1234' response = self.api.delete_account_group_with_http_info( id=id, _headers=self.te_headers("delete_account_group"), ) self.assertEqual(204, response.status_code) self.assertIsNone(response.data) def test_delete_account_group_error_400(self) -> None: """Integration test for delete_account_group error path (HTTP 400)""" id = '1234' error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "errors" : [ { "code" : "code", "field" : "field", "message" : "message" }, { "code" : "code", "field" : "field", "message" : "message" } ], "status" : 0 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(400) ) as context: self.api.delete_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="400"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_error_401(self) -> None: """Integration test for delete_account_group error path (HTTP 401)""" id = '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_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="401"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_error_403(self) -> None: """Integration test for delete_account_group error path (HTTP 403)""" id = '1234' error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(403) ) as context: self.api.delete_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="403"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_error_404(self) -> None: """Integration test for delete_account_group error path (HTTP 404)""" id = '1234' error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(404) ) as context: self.api.delete_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="404"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_error_429(self) -> None: """Integration test for delete_account_group error path (HTTP 429)""" id = '1234' error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(429) ) as context: self.api.delete_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="429"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_delete_account_group_error_500(self) -> None: """Integration test for delete_account_group error path (HTTP 500)""" id = '1234' error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(500) ) as context: self.api.delete_account_group( id=id, _headers=self.te_headers("delete_account_group", error_status="500"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_happy_path(self) -> None: """Integration test for get_account_group success path""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] response_body_json = """ { "isCurrentAccountGroup" : true, "organizationName" : "organizationName", "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "accountGroupName" : "Account A", "isDefaultAccountGroup" : true, "accountToken" : "accountToken", "aid" : "1234", "orgId" : "12345", "users" : [ { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" }, { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" } ], "agents" : [ { "agentId" : "281474976710706", "agentType" : "enterprise-cluster", "ipv6Policy" : "force-ipv4", "prefix" : "99.128.0.0/11", "networkProviderInfo" : { "asn" : 7018, "name" : "AT&T Services, Inc.", "type" : "isp" }, "countryId" : "US", "enabled" : true, "network" : "AT&T Services, Inc. (AS 7018)", "hostname" : "thousandeyes.com", "keepBrowserCache" : true, "agentState" : "online", "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], "serialNumber" : "FOC2218ABCD", "coordinates" : { "latitude" : 37.77493, "longitude" : -122.41942 }, "agentName" : "thousandeyes-stg-va-254", "utilization" : 25, "testIds" : [ 281474976710706 ], "clusterMembers" : [ { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ], "tests" : [ { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" }, { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" } ], "lastSeen" : "2022-07-17T22:00:54Z", "createdDate" : "2022-07-17T22:00:54Z", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "interfaceIpMapping" : [ { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" }, { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" } ], "targetForTests" : "1.1.1.1", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "location" : "San Francisco Bay Area", "accountGroups" : [ { "accountGroupName" : "Account A", "aid" : "1234" }, { "accountGroupName" : "Account A", "aid" : "1234" } ], "verifySslCertificates" : true, "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "agentId" : "281474976710706", "agentType" : "enterprise-cluster", "ipv6Policy" : "force-ipv4", "prefix" : "99.128.0.0/11", "networkProviderInfo" : { "asn" : 7018, "name" : "AT&T Services, Inc.", "type" : "isp" }, "countryId" : "US", "enabled" : true, "network" : "AT&T Services, Inc. (AS 7018)", "hostname" : "thousandeyes.com", "keepBrowserCache" : true, "agentState" : "online", "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], "serialNumber" : "FOC2218ABCD", "coordinates" : { "latitude" : 37.77493, "longitude" : -122.41942 }, "agentName" : "thousandeyes-stg-va-254", "utilization" : 25, "testIds" : [ 281474976710706 ], "clusterMembers" : [ { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ], "tests" : [ { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" }, { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" } ], "lastSeen" : "2022-07-17T22:00:54Z", "createdDate" : "2022-07-17T22:00:54Z", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "interfaceIpMapping" : [ { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" }, { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" } ], "targetForTests" : "1.1.1.1", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "location" : "San Francisco Bay Area", "accountGroups" : [ { "accountGroupName" : "Account A", "aid" : "1234" }, { "accountGroupName" : "Account A", "aid" : "1234" } ], "verifySslCertificates" : true, "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ] } """ expected_response = json.loads(response_body_json) response = self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group"), ) assert_constructed_model_matches_example_json(response, expected_response) def test_get_account_group_error_400(self) -> None: """Integration test for get_account_group error path (HTTP 400)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "errors" : [ { "code" : "code", "field" : "field", "message" : "message" }, { "code" : "code", "field" : "field", "message" : "message" } ], "status" : 0 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(400) ) as context: self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="400"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_error_401(self) -> None: """Integration test for get_account_group error path (HTTP 401)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] 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_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="401"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_error_403(self) -> None: """Integration test for get_account_group error path (HTTP 403)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(403) ) as context: self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="403"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_error_404(self) -> None: """Integration test for get_account_group error path (HTTP 404)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(404) ) as context: self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="404"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_error_429(self) -> None: """Integration test for get_account_group error path (HTTP 429)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(429) ) as context: self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="429"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_group_error_500(self) -> None: """Integration test for get_account_group error path (HTTP 500)""" id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(500) ) as context: self.api.get_account_group( id=id, expand=expand, _headers=self.te_headers("get_account_group", error_status="500"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_happy_path(self) -> None: """Integration test for get_account_groups success path""" response_body_json = """ { "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "accountGroups" : [ { "isCurrentAccountGroup" : true, "organizationName" : "organizationName", "accountGroupName" : "Account A", "isDefaultAccountGroup" : true, "aid" : "1234", "orgId" : "12345" }, { "isCurrentAccountGroup" : true, "organizationName" : "organizationName", "accountGroupName" : "Account A", "isDefaultAccountGroup" : true, "aid" : "1234", "orgId" : "12345" } ] } """ expected_response = json.loads(response_body_json) response = self.api.get_account_groups( _headers=self.te_headers("get_account_groups"), ) assert_constructed_model_matches_example_json(response, expected_response) def test_get_account_groups_error_400(self) -> None: """Integration test for get_account_groups error path (HTTP 400)""" error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "errors" : [ { "code" : "code", "field" : "field", "message" : "message" }, { "code" : "code", "field" : "field", "message" : "message" } ], "status" : 0 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(400) ) as context: self.api.get_account_groups( _headers=self.te_headers("get_account_groups", error_status="400"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_error_401(self) -> None: """Integration test for get_account_groups error path (HTTP 401)""" 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_account_groups( _headers=self.te_headers("get_account_groups", error_status="401"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_error_403(self) -> None: """Integration test for get_account_groups error path (HTTP 403)""" error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(403) ) as context: self.api.get_account_groups( _headers=self.te_headers("get_account_groups", error_status="403"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_error_404(self) -> None: """Integration test for get_account_groups error path (HTTP 404)""" error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(404) ) as context: self.api.get_account_groups( _headers=self.te_headers("get_account_groups", error_status="404"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_error_429(self) -> None: """Integration test for get_account_groups error path (HTTP 429)""" error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(429) ) as context: self.api.get_account_groups( _headers=self.te_headers("get_account_groups", error_status="429"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_get_account_groups_error_500(self) -> None: """Integration test for get_account_groups error path (HTTP 500)""" error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(500) ) as context: self.api.get_account_groups( _headers=self.te_headers("get_account_groups", error_status="500"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_happy_path(self) -> None: """Integration test for update_account_group success path""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] response_body_json = """ { "isCurrentAccountGroup" : true, "organizationName" : "organizationName", "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "accountGroupName" : "Account A", "isDefaultAccountGroup" : true, "accountToken" : "accountToken", "aid" : "1234", "orgId" : "12345", "users" : [ { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" }, { "uid" : "235", "lastLogin" : "2022-07-17T22:00:54Z", "roles" : [ { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true }, { "roleId" : "35", "name" : "Organization Admin", "isBuiltin" : true, "hasManagementPermissions" : true } ], "name" : "User X", "email" : "userx@thousandeyes.com", "dateRegistered" : "2022-07-17T22:00:54Z" } ], "agents" : [ { "agentId" : "281474976710706", "agentType" : "enterprise-cluster", "ipv6Policy" : "force-ipv4", "prefix" : "99.128.0.0/11", "networkProviderInfo" : { "asn" : 7018, "name" : "AT&T Services, Inc.", "type" : "isp" }, "countryId" : "US", "enabled" : true, "network" : "AT&T Services, Inc. (AS 7018)", "hostname" : "thousandeyes.com", "keepBrowserCache" : true, "agentState" : "online", "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], "serialNumber" : "FOC2218ABCD", "coordinates" : { "latitude" : 37.77493, "longitude" : -122.41942 }, "agentName" : "thousandeyes-stg-va-254", "utilization" : 25, "testIds" : [ 281474976710706 ], "clusterMembers" : [ { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ], "tests" : [ { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" }, { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" } ], "lastSeen" : "2022-07-17T22:00:54Z", "createdDate" : "2022-07-17T22:00:54Z", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "interfaceIpMapping" : [ { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" }, { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" } ], "targetForTests" : "1.1.1.1", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "location" : "San Francisco Bay Area", "accountGroups" : [ { "accountGroupName" : "Account A", "aid" : "1234" }, { "accountGroupName" : "Account A", "aid" : "1234" } ], "verifySslCertificates" : true, "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "agentId" : "281474976710706", "agentType" : "enterprise-cluster", "ipv6Policy" : "force-ipv4", "prefix" : "99.128.0.0/11", "networkProviderInfo" : { "asn" : 7018, "name" : "AT&T Services, Inc.", "type" : "isp" }, "countryId" : "US", "enabled" : true, "network" : "AT&T Services, Inc. (AS 7018)", "hostname" : "thousandeyes.com", "keepBrowserCache" : true, "agentState" : "online", "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], "serialNumber" : "FOC2218ABCD", "coordinates" : { "latitude" : 37.77493, "longitude" : -122.41942 }, "agentName" : "thousandeyes-stg-va-254", "utilization" : 25, "testIds" : [ 281474976710706 ], "clusterMembers" : [ { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] }, { "lastSeen" : "2022-07-17T22:00:54Z", "serialNumber" : "FOC2218ABCD", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "agentState" : "online", "targetForTests" : "1.1.1.1", "name" : "Cluster member name", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "utilization" : 25, "network" : "AT&T Services, Inc. (AS 7018)", "memberId" : "10", "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ], "tests" : [ { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" }, { "_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" } }, "liveShare" : false, "savedEvent" : true, "description" : "ThousandEyes Test", "type" : "agent-to-server", "enabled" : true, "createdDate" : "2022-07-17T22:00:54Z", "createdBy" : "user@user.com", "modifiedDate" : "2022-07-17T22:00:54Z", "interval" : 60, "modifiedBy" : "user@user.com", "testId" : "281474976710706", "alertsEnabled" : true, "testName" : "ThousandEyes Test" } ], "lastSeen" : "2022-07-17T22:00:54Z", "createdDate" : "2022-07-17T22:00:54Z", "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], "interfaceIpMapping" : [ { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" }, { "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], "interfaceName" : "wlp4s0" } ], "targetForTests" : "1.1.1.1", "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], "location" : "San Francisco Bay Area", "accountGroups" : [ { "accountGroupName" : "Account A", "aid" : "1234" }, { "accountGroupName" : "Account A", "aid" : "1234" } ], "verifySslCertificates" : true, "errorDetails" : [ { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" }, { "code" : "agent-version-outdated", "description" : "Agent Version 0.1.1 (latest: 1.0.0)" } ] } ] } """ expected_response = json.loads(response_body_json) response = self.api.update_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group"), ) assert_constructed_model_matches_example_json(response, expected_response) def test_update_account_group_error_400(self) -> None: """Integration test for update_account_group error path (HTTP 400)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] 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_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="400"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_error_401(self) -> None: """Integration test for update_account_group error path (HTTP 401)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] 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_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="401"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_error_403(self) -> None: """Integration test for update_account_group error path (HTTP 403)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(403) ) as context: self.api.update_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="403"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_error_404(self) -> None: """Integration test for update_account_group error path (HTTP 404)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(404) ) as context: self.api.update_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="404"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_error_429(self) -> None: """Integration test for update_account_group error path (HTTP 429)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(429) ) as context: self.api.update_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="429"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) def test_update_account_group_error_500(self) -> None: """Integration test for update_account_group error path (HTTP 500)""" request_body_json = """ { "accountGroupName" : "My testing account group", "agents" : [ "105", "719" ] } """ account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) id = '1234' expand = [thousandeyes_sdk.administrative.ExpandAccountGroupOptions()] error_body_json = """ { "instance" : "instance", "detail" : "detail", "type" : "type", "title" : "title", "status" : 6 } """ expected_error = json.loads(error_body_json) with self.assertRaises( ApiException.exception_class_for_http_status(500) ) as context: self.api.update_account_group( id=id, account_group_request=account_group_request, expand=expand, _headers=self.te_headers("update_account_group", error_status="500"), ) assert_constructed_model_matches_example_json(context.exception.data, expected_error) if __name__ == '__main__': unittest.main()