thousandeyes-sdk-python/thousandeyes-sdk-usage/test/test_quotas_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

1281 lines
49 KiB
Python

# coding: utf-8
"""
Usage API
These usage endpoints define the following operations: * **Usage**: Retrieve usage data for the specified time period (default is one month). * Users must have the `View organization usage` permission to access this endpoint. * This operation offers visibility across all account groups within the organization. * Users with `View organization usage` permission in multiple organizations should query the operation with the `aid` query string parameter (see optional parameters) for each organization. * The `agentId` field in enterprise agent unit responses may be omitted when not available. * **Quotas**: Obtain organization and account usage quotas. Additionally, users with the appropriate permissions can create, update, or delete these quotas. * Users must have the necessary permissions to perform quota-related actions. Refer to the Usage API operations for detailed usage instructions and optional parameters.
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.usage.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.usage.api.quotas_api import QuotasApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestQuotasApiIntegration(IntegrationTestBase):
"""QuotasApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = QuotasApi(self.api_client)
def test_assign_organizations_account_groups_quotas_happy_path(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas success path"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
response_body_json = """
{
&quot;organizations&quot; : [ {
&quot;orgId&quot; : &quot;1234&quot;,
&quot;accountGroups&quot; : [ {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
} ]
}, {
&quot;orgId&quot; : &quot;1234&quot;,
&quot;accountGroups&quot; : [ {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
} ]
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_assign_organizations_account_groups_quotas_error_400(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 400)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_account_groups_quotas_error_401(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 401)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_account_groups_quotas_error_403(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 403)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_account_groups_quotas_error_404(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 404)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_account_groups_quotas_error_429(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 429)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_account_groups_quotas_error_500(self) -> None:
"""Integration test for assign_organizations_account_groups_quotas error path (HTTP 500)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
}, {
"orgId" : "1234",
"accountGroups" : [ {
"value" : 12000,
"aid" : "1234"
}, {
"value" : 12000,
"aid" : "1234"
} ]
} ]
}
"""
organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json)
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.assign_organizations_account_groups_quotas(
organizations_quotas_assign=organizations_quotas_assign,
_headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_happy_path(self) -> None:
"""Integration test for assign_organizations_quotas success path"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
response_body_json = """
{
&quot;organizations&quot; : [ {
&quot;orgId&quot; : &quot;1234&quot;,
&quot;value&quot; : 12000
}, {
&quot;orgId&quot; : &quot;12345&quot;,
&quot;value&quot; : 10000
} ]
}
"""
expected_response = json.loads(response_body_json)
response = self.api.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_assign_organizations_quotas_error_400(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 400)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_error_401(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 401)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_error_403(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 403)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_error_404(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 404)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_error_429(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 429)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_assign_organizations_quotas_error_500(self) -> None:
"""Integration test for assign_organizations_quotas error path (HTTP 500)"""
request_body_json = """
{
"organizations" : [ {
"value" : 12000
}, {
"orgId" : "1234",
"value" : 10000
} ]
}
"""
quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json)
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.assign_organizations_quotas(
quotas_assign_request=quotas_assign_request,
_headers=self.te_headers("assign_organizations_quotas", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_happy_path(self) -> None:
"""Integration test for get_quotas success path"""
response_body_json = """
{
&quot;quotas&quot; : [ {
&quot;accountGroupQuotas&quot; : [ {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;value&quot; : 10000,
&quot;aid&quot; : &quot;12345&quot;
} ],
&quot;organizationQuota&quot; : {
&quot;value&quot; : 22500,
&quot;orgId&quot; : &quot;10&quot;
}
}, {
&quot;accountGroupQuotas&quot; : [ {
&quot;value&quot; : 12000,
&quot;aid&quot; : &quot;1234&quot;
}, {
&quot;value&quot; : 10000,
&quot;aid&quot; : &quot;12345&quot;
} ],
&quot;organizationQuota&quot; : {
&quot;value&quot; : 22500,
&quot;orgId&quot; : &quot;10&quot;
}
} ],
&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_quotas(
_headers=self.te_headers("get_quotas"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_quotas_error_400(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_error_401(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_error_403(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_error_404(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_error_429(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_quotas_error_500(self) -> None:
"""Integration test for get_quotas 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_quotas(
_headers=self.te_headers("get_quotas", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_happy_path(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas success path"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
response = self.api.unassign_organizations_account_groups_quotas_with_http_info(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas"),
)
self.assertEqual(204, response.status_code)
self.assertIsNone(response.data)
def test_unassign_organizations_account_groups_quotas_error_400(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 400)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_error_401(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 401)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_error_403(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 403)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_error_404(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 404)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_error_429(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 429)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_account_groups_quotas_error_500(self) -> None:
"""Integration test for unassign_organizations_account_groups_quotas error path (HTTP 500)"""
request_body_json = """
{
"organizations" : [ {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
}, {
"orgId" : "1234",
"accountGroups" : [ "1234", "12345" ]
} ]
}
"""
organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json)
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.unassign_organizations_account_groups_quotas(
organizations_quotas_unassign=organizations_quotas_unassign,
_headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_happy_path(self) -> None:
"""Integration test for unassign_organizations_quotas success path"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
response = self.api.unassign_organizations_quotas_with_http_info(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas"),
)
self.assertEqual(204, response.status_code)
self.assertIsNone(response.data)
def test_unassign_organizations_quotas_error_400(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 400)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_error_401(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 401)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_error_403(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 403)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_error_404(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 404)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_error_429(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 429)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_unassign_organizations_quotas_error_500(self) -> None:
"""Integration test for unassign_organizations_quotas error path (HTTP 500)"""
request_body_json = """
{
"organizations" : [ "1234", "12345" ]
}
"""
quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json)
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.unassign_organizations_quotas(
quotas_unassign=quotas_unassign,
_headers=self.te_headers("unassign_organizations_quotas", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()