def test_get_billing_source_for_provider_error(self): """Test to build Koku Provider billing_source json obj with errors.""" test_matrix = [ { "provider_type": Provider.PROVIDER_AWS, "billing_source": { "data_source": "test-bucket" }, "expected_response": KokuHTTPClientError, }, { "provider_type": Provider.PROVIDER_AZURE, "billing_source": { "bucket": { "foo": "bar" } }, "expected_response": KokuHTTPClientError, }, ] client = KokuHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER) for test in test_matrix: with self.assertRaises(test.get("expected_response")): client.get_billing_source_for_provider( test.get("provider_type"), test.get("billing_source"))
def test_get_billing_source_for_provider_error(self): """Test to build Koku Provider billing_source json obj with errors.""" test_matrix = [{'provider_type': 'AWS', 'billing_source': {'data_source': 'test-bucket'}, 'expected_response': KokuHTTPClientError}, {'provider_type': 'AZURE', 'billing_source': {'bucket': {'foo': 'bar'}}, 'expected_response': KokuHTTPClientError} ] client = KokuHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER) for test in test_matrix: with self.assertRaises(test.get('expected_response')): client.get_billing_source_for_provider(test.get('provider_type'), test.get('billing_source'))
def test_get_billing_source_for_provider(self): """Test to build Koku Provider billing_source json obj.""" test_matrix = [{'provider_type': 'AWS', 'billing_source': {'bucket': 'test-bucket'}, 'expected_response': {'bucket': 'test-bucket'}}, {'provider_type': 'OCP', 'billing_source': {'bucket': ''}, 'expected_response': {'bucket': ''}}, {'provider_type': 'AZURE', 'billing_source': {'data_source': {'foo': 'bar'}}, 'expected_response': {'data_source': {'foo': 'bar'}}} ] client = KokuHTTPClient(auth_header=Config.SOURCES_FAKE_HEADER) for test in test_matrix: response = client.get_billing_source_for_provider(test.get('provider_type'), test.get('billing_source')) self.assertEqual(response, test.get('expected_response'))