# coding: utf-8

"""
    Internet Insights API

    **Note:** All Internet Insights APIs are not available for ThousandEyes for Government instance.  We are happy to announce the release of the Internet Insights API set. This limited release includes endpoints that:  * Make our catalog provider and Internet outage data accessible to API users. * Provide access to advanced filtering, which is part of our next-generation API efforts to allow API users to fine-tune queries across all of our APIs in a consistent manner.  Internet Insights provide visibility into core Internet infrastructure, including ISPs, DNS providers, IaaS, CDNs , and SaaS providers. It tracks the macro-level impact of Internet events on individual users and enterprise networks connecting at the edge of the Internet. These events include Outages, Routing hijacks and leaks, DDoS attacks, And political interference, among others.  Future releases of the Internet Insights API set will further unlock access to core Internet Insights functionality, unlocking potential integrations to enrich customer process flows.  For more information about Internet Insights, see the [Internet Insights](https://docs.thousandeyes.com/product-documentation/internet-insights). 

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

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


import json
import unittest
import thousandeyes_sdk.internet_insights.models

from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.internet_insights.api.internet_insights_catalog_providers_api import InternetInsightsCatalogProvidersApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json


class TestInternetInsightsCatalogProvidersApiIntegration(IntegrationTestBase):
    """InternetInsightsCatalogProvidersApi integration test stubs"""

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


    def test_filter_catalog_providers_happy_path(self) -> None:
        """Integration test for filter_catalog_providers success path"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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"
                    }
                  },
                  "providers" : [ {
                    "interfacesCount" : 15,
                    "locationsCount" : 50,
                    "_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"
                      }
                    },
                    "countriesCount" : 2,
                    "dataType" : "Application",
                    "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26",
                    "region" : "North America",
                    "asnsCount" : 10,
                    "included" : true,
                    "providerName" : "Amazon Web Services",
                    "providerType" : "IAAS"
                  }, {
                    "interfacesCount" : 15,
                    "locationsCount" : 50,
                    "_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"
                      }
                    },
                    "countriesCount" : 2,
                    "dataType" : "Application",
                    "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26",
                    "region" : "North America",
                    "asnsCount" : 10,
                    "included" : true,
                    "providerName" : "Amazon Web Services",
                    "providerType" : "IAAS"
                  } ]
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.filter_catalog_providers(

            api_catalog_provider_filter=api_catalog_provider_filter,

            aid=aid,

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


    def test_filter_catalog_providers_error_400(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 400)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_401(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 401)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_403(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 403)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_404(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 404)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_429(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 429)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_500(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 500)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

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


    def test_filter_catalog_providers_error_502(self) -> None:
        """Integration test for filter_catalog_providers error path (HTTP 502)"""
        request_body_json = """
        
                {
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS",
                  "region" : "North America",
                  "location" : "San Jose, US",
                  "asn" : "Amazon.com, Inc.",
                  "included" : true
                }
        
                """
        api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.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(502)
        ) as context:
            self.api.filter_catalog_providers(

                api_catalog_provider_filter=api_catalog_provider_filter,

                aid=aid,

                _headers=self.te_headers("filter_catalog_providers", error_status="502"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)




    def test_get_catalog_provider_happy_path(self) -> None:
        """Integration test for get_catalog_provider success path"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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"
                    }
                  },
                  "dataType" : "Application",
                  "asns" : [ {
                    "name" : "LVLT-1 - Level 3 Communications, Inc.",
                    "id" : 1
                  }, {
                    "name" : "LVLT-1 - Level 3 Communications, Inc.",
                    "id" : 1
                  } ],
                  "locations" : [ {
                    "interfacesCount" : 5,
                    "location" : "San Jose, US"
                  }, {
                    "interfacesCount" : 5,
                    "location" : "San Jose, US"
                  } ],
                  "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26",
                  "region" : "North America",
                  "providerName" : "Amazon Web Services",
                  "providerType" : "IAAS"
                }
                """
        expected_response = json.loads(response_body_json)
        response = self.api.get_catalog_provider(

            provider_id=provider_id,

            aid=aid,

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


    def test_get_catalog_provider_error_400(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 400)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_401(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 401)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_403(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 403)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_404(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 404)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_429(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 429)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_500(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 500)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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_catalog_provider(

                provider_id=provider_id,

                aid=aid,

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


    def test_get_catalog_provider_error_502(self) -> None:
        """Integration test for get_catalog_provider error path (HTTP 502)"""
        provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26'
        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(502)
        ) as context:
            self.api.get_catalog_provider(

                provider_id=provider_id,

                aid=aid,

                _headers=self.te_headers("get_catalog_provider", error_status="502"),
            )
        assert_constructed_model_matches_example_json(context.exception.data, expected_error)






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