# coding: utf-8

"""
    Credentials API

    Manage credentials for transaction tests using the Credentials API.  The following permissions are required to access Credentials API operations:  * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials.  For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials). 

    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import json
import unittest
import thousandeyes_sdk.credentials.models

from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.credentials.api.credentials_api import CredentialsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json


class TestCredentialsApiIntegration(IntegrationTestBase):
    """CredentialsApi integration test stubs"""

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


    def test_create_credential_happy_path(self) -> None:
        """Integration test for create_credential success path"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.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"
                    }
                  },
                  "name" : "Example Credential",
                  "id" : "3247"
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.create_credential(

            credential_request=credential_request,

            aid=aid,

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


    def test_create_credential_error_400(self) -> None:
        """Integration test for create_credential error path (HTTP 400)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.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_credential(

                credential_request=credential_request,

                aid=aid,

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


    def test_create_credential_error_401(self) -> None:
        """Integration test for create_credential error path (HTTP 401)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.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_credential(

                credential_request=credential_request,

                aid=aid,

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


    def test_create_credential_error_403(self) -> None:
        """Integration test for create_credential error path (HTTP 403)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.create_credential(

                credential_request=credential_request,

                aid=aid,

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


    def test_create_credential_error_404(self) -> None:
        """Integration test for create_credential error path (HTTP 404)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.create_credential(

                credential_request=credential_request,

                aid=aid,

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


    def test_create_credential_error_429(self) -> None:
        """Integration test for create_credential error path (HTTP 429)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.create_credential(

                credential_request=credential_request,

                aid=aid,

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


    def test_create_credential_error_500(self) -> None:
        """Integration test for create_credential error path (HTTP 500)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.create_credential(

                credential_request=credential_request,

                aid=aid,

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




    def test_delete_credential_happy_path(self) -> None:
        """Integration test for delete_credential success path"""
        id = '3247'
        aid = '1234'
        response = self.api.delete_credential_with_http_info(

            id=id,

            aid=aid,

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


    def test_delete_credential_error_401(self) -> None:
        """Integration test for delete_credential error path (HTTP 401)"""
        id = '3247'
        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_credential(

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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




    def test_get_credential_happy_path(self) -> None:
        """Integration test for get_credential success path"""
        id = '3247'
        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"
                    }
                  },
                  "name" : "Example Credential",
                  "id" : "3247",
                  "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.get_credential(

            id=id,

            aid=aid,

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


    def test_get_credential_error_400(self) -> None:
        """Integration test for get_credential error path (HTTP 400)"""
        id = '3247'
        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_credential(

                id=id,

                aid=aid,

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


    def test_get_credential_error_401(self) -> None:
        """Integration test for get_credential error path (HTTP 401)"""
        id = '3247'
        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_credential(

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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


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

                id=id,

                aid=aid,

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




    def test_get_credentials_happy_path(self) -> None:
        """Integration test for get_credentials success path"""
        aid = '1234'
        response_body_json = """
                {
                  "credentials" : [ {
                    "_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"
                      }
                    },
                    "name" : "Example Credential",
                    "id" : "3247",
                    "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
                  }, {
                    "_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"
                      }
                    },
                    "name" : "Example Credential",
                    "id" : "3247",
                    "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt"
                  } ],
                  "_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"
                    }
                  }
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.get_credentials(

            aid=aid,

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


    def test_get_credentials_error_401(self) -> None:
        """Integration test for get_credentials 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_credentials(

                aid=aid,

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


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

                aid=aid,

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


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

                aid=aid,

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


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

                aid=aid,

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


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

                aid=aid,

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




    def test_update_credential_happy_path(self) -> None:
        """Integration test for update_credential success path"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        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"
                    }
                  },
                  "name" : "Example Credential",
                  "id" : "3247"
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.update_credential(

            id=id,

            credential_request=credential_request,

            aid=aid,

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


    def test_update_credential_error_400(self) -> None:
        """Integration test for update_credential error path (HTTP 400)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        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_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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


    def test_update_credential_error_401(self) -> None:
        """Integration test for update_credential error path (HTTP 401)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        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_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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


    def test_update_credential_error_403(self) -> None:
        """Integration test for update_credential error path (HTTP 403)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(403)
        ) as context:
            self.api.update_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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


    def test_update_credential_error_404(self) -> None:
        """Integration test for update_credential error path (HTTP 404)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(404)
        ) as context:
            self.api.update_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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


    def test_update_credential_error_429(self) -> None:
        """Integration test for update_credential error path (HTTP 429)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(429)
        ) as context:
            self.api.update_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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


    def test_update_credential_error_500(self) -> None:
        """Integration test for update_credential error path (HTTP 500)"""
        request_body_json = """
        
                {
                  "name" : "Example Credential 1",
                  "value" : "Example Credential 1 Password"
                }
        
                """
        credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json)
        id = '3247'
        aid = '1234'
        error_body_json = """
                {
                  "instance" : "instance",
                  "detail" : "detail",
                  "type" : "type",
                  "title" : "title",
                  "status" : 0
                }
                """
        expected_error = json.loads(error_body_json)
        with self.assertRaises(
            ApiException.exception_class_for_http_status(500)
        ) as context:
            self.api.update_credential(

                id=id,

                credential_request=credential_request,

                aid=aid,

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






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