Skip to content

Commit

Permalink
Rename status methods, fix test fragility and recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp committed Oct 2, 2020
1 parent 0305d06 commit 4ffb858
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 509 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def begin_selective_restore(self, blob_storage_uri, sas_token, folder_name, key_
**kwargs
)

def full_backup_status(self, job_id, **kwargs):
def get_backup_status(self, job_id, **kwargs):
# type: (str, **Any) -> BackupOperation
"""Returns the status of a full backup operation.
Expand All @@ -110,7 +110,7 @@ def full_backup_status(self, job_id, **kwargs):
**kwargs
)

def restore_status(self, job_id, **kwargs):
def get_restore_status(self, job_id, **kwargs):
# type: (str, **Any) -> RestoreOperation
"""Returns the status of a restore operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def begin_selective_restore(
**kwargs
)

async def full_backup_status(
async def get_backup_status(
self, job_id: str, **kwargs: "Any"
) -> "BackupOperation":
"""Returns the status of a full backup operation.
Expand All @@ -119,7 +119,7 @@ async def full_backup_status(
**kwargs
)

async def restore_status(
async def get_restore_status(
self, job_id: str, **kwargs: "Any"
) -> "RestoreOperation":
"""Returns the status of a restore operation.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# Licensed under the MIT License.
# ------------------------------------
from datetime import datetime
from functools import partial
import time

from azure.core.credentials import AccessToken
from azure.core.exceptions import ResourceExistsError
from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient
from azure.keyvault.administration import KeyVaultBackupClient, BackupOperation
Expand Down Expand Up @@ -43,11 +45,11 @@ def test_full_backup_and_restore(self, container_uri, sas_token):

# check backup status and result
job_id = backup_poller.polling_method().resource().id
backup_status = backup_client.full_backup_status(job_id)
backup_status = backup_client.get_backup_status(job_id)
assert_in_progress_operation(backup_status)
backup_operation = backup_poller.result()
assert_successful_operation(backup_operation)
backup_status = backup_client.full_backup_status(job_id)
backup_status = backup_client.get_backup_status(job_id)
assert_successful_operation(backup_status)

# restore the backup
Expand All @@ -56,11 +58,11 @@ def test_full_backup_and_restore(self, container_uri, sas_token):

# check restore status and result
job_id = restore_poller.polling_method().resource().id
restore_status = backup_client.restore_status(job_id)
restore_status = backup_client.get_restore_status(job_id)
assert_in_progress_operation(restore_status)
restore_operation = restore_poller.result()
assert_successful_operation(restore_operation)
restore_status = backup_client.restore_status(job_id)
restore_status = backup_client.get_restore_status(job_id)
assert_successful_operation(restore_status)

@ResourceGroupPreparer(random_name_enabled=True, use_cache=True)
Expand All @@ -78,11 +80,11 @@ def test_selective_key_restore(self, container_uri, sas_token):

# check backup status and result
job_id = backup_poller.polling_method().resource().id
backup_status = backup_client.full_backup_status(job_id)
backup_status = backup_client.get_backup_status(job_id)
assert_in_progress_operation(backup_status)
backup_operation = backup_poller.result()
assert_successful_operation(backup_operation)
backup_status = backup_client.full_backup_status(job_id)
backup_status = backup_client.get_backup_status(job_id)
assert_successful_operation(backup_status)

# restore the key
Expand All @@ -91,14 +93,17 @@ def test_selective_key_restore(self, container_uri, sas_token):

# check restore status and result
job_id = restore_poller.polling_method().resource().id
restore_status = backup_client.restore_status(job_id)
restore_status = backup_client.get_restore_status(job_id)
assert_in_progress_operation(restore_status)
restore_operation = restore_poller.result()
assert_successful_operation(restore_operation)
restore_status = backup_client.restore_status(job_id)
restore_status = backup_client.get_restore_status(job_id)
assert_successful_operation(restore_status)

key_client.begin_delete_key(key_name).wait()
# delete the key
delete_function = partial(key_client.begin_delete_key, key_name)
delete_poller = self._poll_until_no_exception(delete_function, ResourceExistsError)
delete_poller.wait()
key_client.purge_deleted_key(key_name)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from unittest import mock

from azure.core.credentials import AccessToken
from azure.core.exceptions import ResourceExistsError
from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.keys.aio import KeyClient
from azure.keyvault.administration.aio import KeyVaultBackupClient
Expand Down Expand Up @@ -50,11 +51,11 @@ async def test_full_backup_and_restore(self, container_uri, sas_token):

# check backup status and result
job_id = backup_poller.polling_method().resource().id
backup_status = await backup_client.full_backup_status(job_id)
backup_status = await backup_client.get_backup_status(job_id)
assert_in_progress_operation(backup_status)
backup_operation = await backup_poller.result()
assert_successful_operation(backup_operation)
backup_status = await backup_client.full_backup_status(job_id)
backup_status = await backup_client.get_backup_status(job_id)
assert_successful_operation(backup_status)

# restore the backup
Expand All @@ -63,11 +64,11 @@ async def test_full_backup_and_restore(self, container_uri, sas_token):

# check restore status and result
job_id = restore_poller.polling_method().resource().id
restore_status = await backup_client.restore_status(job_id)
restore_status = await backup_client.get_restore_status(job_id)
assert_in_progress_operation(restore_status)
restore_operation = await restore_poller.result()
assert_successful_operation(restore_operation)
restore_status = await backup_client.restore_status(job_id)
restore_status = await backup_client.get_restore_status(job_id)
assert_successful_operation(restore_status)

@ResourceGroupPreparer(random_name_enabled=True, use_cache=True)
Expand All @@ -85,11 +86,11 @@ async def test_selective_key_restore(self, container_uri, sas_token):

# check backup status and result
job_id = backup_poller.polling_method().resource().id
backup_status = await backup_client.full_backup_status(job_id)
backup_status = await backup_client.get_backup_status(job_id)
assert_in_progress_operation(backup_status)
backup_operation = await backup_poller.result()
assert_successful_operation(backup_operation)
backup_status = await backup_client.full_backup_status(job_id)
backup_status = await backup_client.get_backup_status(job_id)
assert_successful_operation(backup_status)

# restore the key
Expand All @@ -98,14 +99,15 @@ async def test_selective_key_restore(self, container_uri, sas_token):

# check restore status and result
job_id = restore_poller.polling_method().resource().id
restore_status = await backup_client.restore_status(job_id)
restore_status = await backup_client.get_restore_status(job_id)
assert_in_progress_operation(restore_status)
restore_operation = await restore_poller.result()
assert_successful_operation(restore_operation)
restore_status = await backup_client.restore_status(job_id)
restore_status = await backup_client.get_restore_status(job_id)
assert_successful_operation(restore_status)

await key_client.delete_key(key_name)
# delete the key
await self._poll_until_no_exception(key_client.delete_key, key_name, expected_exception=ResourceExistsError)
await key_client.purge_deleted_key(key_name)


Expand Down

0 comments on commit 4ffb858

Please sign in to comment.