예제 #1
0
    def test_cost_usage_source_reachable_without_cost_export(self, _):
        """Test that cost_usage_source_is_reachable raises an exception when no cost reports exist."""
        credentials = {
            "subscription_id": FAKE.uuid4(),
            "tenant_id": FAKE.uuid4(),
            "client_id": FAKE.uuid4(),
            "client_secret": FAKE.word(),
        }
        source_name = {
            "resource_group": FAKE.word(),
            "storage_account": FAKE.word()
        }

        with patch("providers.azure.provider.AzureService") as MockHelper:
            MockHelper.return_value.describe_cost_management_exports.return_value = []
            azure_provider = AzureProvider()
            with self.assertRaises(ValidationError):
                azure_provider.cost_usage_source_is_reachable(
                    credentials, source_name)
예제 #2
0
 def test_cost_usage_source_is_reachable_valid(self, _):
     """Test that cost_usage_source_is_reachable succeeds."""
     credentials = {
         'subscription_id': FAKE.uuid4(),
         'tenant_id': FAKE.uuid4(),
         'client_id': FAKE.uuid4(),
         'client_secret': FAKE.word()
     }
     source_name = {
         'resource_group': FAKE.word(),
         'storage_account': FAKE.word()
     }
     obj = AzureProvider()
     self.assertTrue(
         obj.cost_usage_source_is_reachable(credentials, source_name))
예제 #3
0
 def test_cost_usage_source_is_reachable_valid(self, _):
     """Test that cost_usage_source_is_reachable succeeds."""
     credentials = {
         "subscription_id": FAKE.uuid4(),
         "tenant_id": FAKE.uuid4(),
         "client_id": FAKE.uuid4(),
         "client_secret": FAKE.word(),
     }
     source_name = {
         "resource_group": FAKE.word(),
         "storage_account": FAKE.word()
     }
     with patch("providers.azure.provider.AzureService") as MockHelper:
         MockHelper.return_value.describe_cost_management_exports.return_value = [
             "report1"
         ]
         obj = AzureProvider()
         self.assertTrue(
             obj.cost_usage_source_is_reachable(credentials, source_name))