Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions tests/integration/test_client_crud_lifecycle_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ async def test_delete_policy_objects(dashboard, org_id, version_salt):
async def test_delete_network(dashboard, org_id, network):
import asyncio
from meraki.api.batch.networks import ActionBatchNetworks
from meraki.exceptions import AsyncAPIError

action = ActionBatchNetworks().deleteNetwork(network["id"])
max_attempts = 5
Expand All @@ -209,12 +210,21 @@ async def test_delete_network(dashboard, org_id, network):
delay = 2**attempt

await asyncio.sleep(delay)
batch = await dashboard.organizations.createOrganizationActionBatch(
organizationId=org_id,
actions=[action],
confirmed=False,
synchronous=False,
)
try:
batch = await dashboard.organizations.createOrganizationActionBatch(
organizationId=org_id,
actions=[action],
confirmed=False,
synchronous=False,
)
except AsyncAPIError as e:
# Action batches are asynchronous: a prior attempt's batch can
# finish deleting the network after we stopped observing it. The
# network being gone is the desired end state, so a "not found"
# here means the delete already succeeded.
if e.status == 400 and "not found" in str(e.message).lower():
return
raise
assert batch is not None
assert batch["id"]

Expand Down
22 changes: 16 additions & 6 deletions tests/integration/test_client_crud_lifecycle_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def test_delete_policy_objects(dashboard, org_id, version_salt):
def test_delete_network(dashboard, org_id, network):
import time
from meraki.api.batch.networks import ActionBatchNetworks
from meraki.exceptions import APIError

action = ActionBatchNetworks().deleteNetwork(network["id"])
max_attempts = 5
Expand All @@ -216,12 +217,21 @@ def test_delete_network(dashboard, org_id, network):
delay = 2**attempt

time.sleep(delay)
batch = dashboard.organizations.createOrganizationActionBatch(
organizationId=org_id,
actions=[action],
confirmed=False,
synchronous=False,
)
try:
batch = dashboard.organizations.createOrganizationActionBatch(
organizationId=org_id,
actions=[action],
confirmed=False,
synchronous=False,
)
except APIError as e:
# Action batches are asynchronous: a prior attempt's batch can
# finish deleting the network after we stopped observing it. The
# network being gone is the desired end state, so a "not found"
# here means the delete already succeeded.
if e.status == 400 and "not found" in str(e.message).lower():
return
raise
assert batch is not None
assert batch["id"]

Expand Down
Loading