Skip to content

Commit

Permalink
[T2 aiotest] keyvault (#11646)
Browse files Browse the repository at this point in the history
* add aio test for keyvault

* add .result for async poller
  • Loading branch information
00Kai0 authored and Zim Kalinowski committed Jun 6, 2020
1 parent fae2266 commit 9377574
Show file tree
Hide file tree
Showing 3 changed files with 1,180 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sdk/keyvault/azure-mgmt-keyvault/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import asyncio
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from azure.identity.aio import DefaultAzureCredential
from devtools_testutils import AzureMgmtTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()

@property
def event_loop(self):
return asyncio.get_event_loop()

def create_mgmt_aio_client(self, client, **kwargs):
if self.is_live:
credential = DefaultAzureCredential()
else:
credential = Mock(get_token=asyncio.coroutine(lambda _: AccessToken("fake-token", 0)))
return client(
credential=credential,
subscription_id=self.settings.SUBSCRIPTION_ID
)

def to_list(self, ait):
async def lst():
result = []
async for item in ait:
result.append(item)
return result
return self.event_loop.run_until_complete(lst())
Loading

0 comments on commit 9377574

Please sign in to comment.