def test_blob_service_client_property(monkeypatch, secret_name, secret_arg): connection = MagicMock() azure = MagicMock(from_connection_string=connection) monkeypatch.setattr("azure.storage.blob.BlobServiceClient", azure) with context(secrets={secret_name: secret_arg}): storage = Azure(container="test", connection_string_secret=secret_name) client = storage._azure_block_blob_service() azure_client = storage._azure_block_blob_service assert storage.connection_string == secret_arg assert azure_client connection.assert_called_with(conn_str=secret_arg)
def test_blob_service_client_property(monkeypatch, secret_name, secret_arg, credential): connection = MagicMock() azure = MagicMock(from_connection_string=connection) monkeypatch.setattr("azure.storage.blob.BlobServiceClient", azure) monkeypatch.setattr("azure.identity.DefaultAzureCredential", credential) with context(secrets={secret_name: secret_arg}): storage = Azure(container="test", connection_string_secret=secret_name) client = storage._azure_block_blob_service() azure_client = storage._azure_block_blob_service assert storage.connection_string == secret_arg assert azure_client if credential is None: connection.assert_called_with(conn_str=secret_arg, credential=None) else: connection.assert_called_with(conn_str=secret_arg, credential=credential())