コード例 #1
0
 def test_get_cost_management_application_type_id_error(self):
     """Test to get application type id with error."""
     client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER)
     with requests_mock.mock() as m:
         m.get(
             f'http://www.sources.com/api/v1.0/application_types?filter[name]=/insights/platform/cost-management',
             exc=requests.exceptions.RequestException)
         with self.assertRaises(SourcesHTTPClientError):
             client.get_cost_management_application_type_id()
コード例 #2
0
 def test_get_cost_management_application_type_id_not_found(self):
     """Test to get application type id with invalid prefix."""
     client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER)
     with requests_mock.mock() as m:
         m.get(
             "http://www.sources.com/api/v1.0/application_types?filter[name]=/insights/platform/cost-management",
             status_code=404,
             json={"data": [{"id": self.application_type}]},
         )
         with self.assertRaises(SourceNotFoundError):
             client.get_cost_management_application_type_id()
コード例 #3
0
 def test_get_cost_management_application_type_id_exceptions(self):
     """Test to get application type id with invalid prefix."""
     client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER)
     json_data = [None, [], [{"not_id": 4}]]
     for test in json_data:
         with self.subTest(test=test):
             with requests_mock.mock() as m:
                 m.get(
                     f"{MOCK_URL}/api/v1.0/{ENDPOINT_APPLICATION_TYPES}?filter[name]=/insights/platform/cost-management",  # noqa: E501
                     json={"data": test},
                 )
                 with self.assertRaises(SourcesHTTPClientError):
                     client.get_cost_management_application_type_id()
コード例 #4
0
 def test_get_cost_management_application_type_id(self):
     """Test to get application type id."""
     client = SourcesHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER)
     with requests_mock.mock() as m:
         m.get(
             "http://www.sources.com/api/v1.0/application_types?filter[name]=/insights/platform/cost-management",
             status_code=200,
             json={"data": [{"id": self.application_type}]},
         )
         response = client.get_cost_management_application_type_id()
         self.assertEqual(response, self.application_type)