# 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.roles_api import RolesApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json


class TestRolesApiIntegration(IntegrationTestBase):
    """RolesApi integration test stubs"""

    def setUp(self) -> None:
        super().setUp()
        self.api = RolesApi(self.api_client)


    def test_create_role_happy_path(self) -> None:
        """Integration test for create_role success path"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        response_body_json = """
                {
                  "_links" : {
                    "self" : {
                      "hreflang" : "hreflang",
                      "templated" : true,
                      "profile" : "profile",
                      "name" : "name",
                      "href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
                      "type" : "type",
                      "deprecation" : "deprecation",
                      "title" : "title"
                    }
                  },
                  "roleId" : "35",
                  "permissions" : [ {
                    "label" : "View reports",
                    "permissionId" : "1",
                    "isManagementPermission" : true,
                    "permission" : "REPORT_READ"
                  }, {
                    "label" : "View snapshots",
                    "permissionId" : "51",
                    "isManagementPermission" : false,
                    "permission" : "REPORT_SNAPSHOTS_READ"
                  } ],
                  "name" : "Organization Admin",
                  "isBuiltin" : true
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.create_role(

            role_request_body=role_request_body,

            aid=aid,

            _headers=self.te_headers("create_role"),
        )
        assert_constructed_model_matches_example_json(response, expected_response)


    def test_create_role_error_400(self) -> None:
        """Integration test for create_role error path (HTTP 400)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "errors" : [ {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  }, {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  } ],
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(400)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="400"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_create_role_error_401(self) -> None:
        """Integration test for create_role error path (HTTP 401)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "error_description" : "Invalid access token",
                  "error" : "invalid_token"
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(401)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="401"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_create_role_error_403(self) -> None:
        """Integration test for create_role error path (HTTP 403)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="403"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_create_role_error_404(self) -> None:
        """Integration test for create_role error path (HTTP 404)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="404"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_create_role_error_429(self) -> None:
        """Integration test for create_role error path (HTTP 429)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="429"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_create_role_error_500(self) -> None:
        """Integration test for create_role error path (HTTP 500)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.create_role(

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("create_role", error_status="500"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)




    def test_delete_role_happy_path(self) -> None:
        """Integration test for delete_role success path"""
        id = '23'
        aid = '1234'
        response = self.api.delete_role_with_http_info(

            id=id,

            aid=aid,

            _headers=self.te_headers("delete_role"),
        )
        self.assertEqual(204, response.status_code)
        self.assertIsNone(response.data)


    def test_delete_role_error_400(self) -> None:
        """Integration test for delete_role error path (HTTP 400)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "errors" : [ {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  }, {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  } ],
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(400)
        ) as context:
            self.api.delete_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="400"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_delete_role_error_401(self) -> None:
        """Integration test for delete_role error path (HTTP 401)"""
        id = '23'
        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_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="401"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_delete_role_error_403(self) -> None:
        """Integration test for delete_role error path (HTTP 403)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.delete_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="403"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_delete_role_error_404(self) -> None:
        """Integration test for delete_role error path (HTTP 404)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.delete_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="404"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_delete_role_error_429(self) -> None:
        """Integration test for delete_role error path (HTTP 429)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.delete_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="429"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_delete_role_error_500(self) -> None:
        """Integration test for delete_role error path (HTTP 500)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.delete_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("delete_role", error_status="500"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)




    def test_get_role_happy_path(self) -> None:
        """Integration test for get_role success path"""
        id = '23'
        aid = '1234'
        response_body_json = """
                {
                  "_links" : {
                    "self" : {
                      "hreflang" : "hreflang",
                      "templated" : true,
                      "profile" : "profile",
                      "name" : "name",
                      "href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
                      "type" : "type",
                      "deprecation" : "deprecation",
                      "title" : "title"
                    }
                  },
                  "roleId" : "35",
                  "permissions" : [ {
                    "label" : "View reports",
                    "permissionId" : "1",
                    "isManagementPermission" : true,
                    "permission" : "REPORT_READ"
                  }, {
                    "label" : "View snapshots",
                    "permissionId" : "51",
                    "isManagementPermission" : false,
                    "permission" : "REPORT_SNAPSHOTS_READ"
                  } ],
                  "name" : "Organization Admin",
                  "isBuiltin" : true
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.get_role(

            id=id,

            aid=aid,

            _headers=self.te_headers("get_role"),
        )
        assert_constructed_model_matches_example_json(response, expected_response)


    def test_get_role_error_400(self) -> None:
        """Integration test for get_role error path (HTTP 400)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "errors" : [ {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  }, {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  } ],
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(400)
        ) as context:
            self.api.get_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="400"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_role_error_401(self) -> None:
        """Integration test for get_role error path (HTTP 401)"""
        id = '23'
        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_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="401"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_role_error_403(self) -> None:
        """Integration test for get_role error path (HTTP 403)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.get_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="403"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_role_error_404(self) -> None:
        """Integration test for get_role error path (HTTP 404)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.get_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="404"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_role_error_429(self) -> None:
        """Integration test for get_role error path (HTTP 429)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.get_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="429"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_role_error_500(self) -> None:
        """Integration test for get_role error path (HTTP 500)"""
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.get_role(

                id=id,

                aid=aid,

                _headers=self.te_headers("get_role", error_status="500"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)




    def test_get_roles_happy_path(self) -> None:
        """Integration test for get_roles success path"""
        aid = '1234'
        response_body_json = """
                {
                  "_links" : {
                    "self" : {
                      "hreflang" : "hreflang",
                      "templated" : true,
                      "profile" : "profile",
                      "name" : "name",
                      "href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
                      "type" : "type",
                      "deprecation" : "deprecation",
                      "title" : "title"
                    }
                  },
                  "roles" : [ {
                    "roleId" : "35",
                    "name" : "Organization Admin",
                    "isBuiltin" : true,
                    "hasManagementPermissions" : true
                  }, {
                    "roleId" : "35",
                    "name" : "Organization Admin",
                    "isBuiltin" : true,
                    "hasManagementPermissions" : true
                  } ]
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.get_roles(

            aid=aid,

            _headers=self.te_headers("get_roles"),
        )
        assert_constructed_model_matches_example_json(response, expected_response)


    def test_get_roles_error_400(self) -> None:
        """Integration test for get_roles error path (HTTP 400)"""
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "errors" : [ {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  }, {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  } ],
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(400)
        ) as context:
            self.api.get_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="400"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_roles_error_401(self) -> None:
        """Integration test for get_roles 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_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="401"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_roles_error_403(self) -> None:
        """Integration test for get_roles error path (HTTP 403)"""
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.get_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="403"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_roles_error_404(self) -> None:
        """Integration test for get_roles error path (HTTP 404)"""
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.get_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="404"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_roles_error_429(self) -> None:
        """Integration test for get_roles error path (HTTP 429)"""
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.get_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="429"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_get_roles_error_500(self) -> None:
        """Integration test for get_roles error path (HTTP 500)"""
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.get_roles(

                aid=aid,

                _headers=self.te_headers("get_roles", error_status="500"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)




    def test_update_role_happy_path(self) -> None:
        """Integration test for update_role success path"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        response_body_json = """
                {
                  "_links" : {
                    "self" : {
                      "hreflang" : "hreflang",
                      "templated" : true,
                      "profile" : "profile",
                      "name" : "name",
                      "href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
                      "type" : "type",
                      "deprecation" : "deprecation",
                      "title" : "title"
                    }
                  },
                  "roleId" : "35",
                  "permissions" : [ {
                    "label" : "View reports",
                    "permissionId" : "1",
                    "isManagementPermission" : true,
                    "permission" : "REPORT_READ"
                  }, {
                    "label" : "View snapshots",
                    "permissionId" : "51",
                    "isManagementPermission" : false,
                    "permission" : "REPORT_SNAPSHOTS_READ"
                  } ],
                  "name" : "Organization Admin",
                  "isBuiltin" : true
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.update_role(

            id=id,

            role_request_body=role_request_body,

            aid=aid,

            _headers=self.te_headers("update_role"),
        )
        assert_constructed_model_matches_example_json(response, expected_response)


    def test_update_role_error_400(self) -> None:
        """Integration test for update_role error path (HTTP 400)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "errors" : [ {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  }, {
                    "code" : "code",
                    "field" : "field",
                    "message" : "message"
                  } ],
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(400)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="400"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_update_role_error_401(self) -> None:
        """Integration test for update_role error path (HTTP 401)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "error_description" : "Invalid access token",
                  "error" : "invalid_token"
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(401)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="401"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_update_role_error_403(self) -> None:
        """Integration test for update_role error path (HTTP 403)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="403"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_update_role_error_404(self) -> None:
        """Integration test for update_role error path (HTTP 404)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="404"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_update_role_error_429(self) -> None:
        """Integration test for update_role error path (HTTP 429)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="429"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)


    def test_update_role_error_500(self) -> None:
        """Integration test for update_role error path (HTTP 500)"""
        request_body_json = """
        
                {
                  "permissions" : [ "56", "315" ],
                  "name" : "Organization Admin"
                }
        
                """
        role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json)
        id = '23'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 6
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.update_role(

                id=id,

                role_request_body=role_request_body,

                aid=aid,

                _headers=self.te_headers("update_role", error_status="500"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)






if __name__ == '__main__':
    unittest.main()
