Skip to content

Handle delete Not Found exceptions if needed #1778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 19, 2018
Merged
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: 15 additions & 7 deletions dns/api/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

from gcp_devrel.testing.flaky import flaky
from google.cloud import dns
from google.cloud.exceptions import NotFound

import pytest

import main
Expand All @@ -33,7 +35,10 @@ def client():

# Delete anything created during the test.
for zone in client.list_zones():
zone.delete()
try:
zone.delete()
except NotFound: # May have been in process
pass


@pytest.yield_fixture
Expand All @@ -45,7 +50,10 @@ def zone(client):
yield zone

if zone.exists():
zone.delete()
try:
zone.delete()
except NotFound: # May have been under way
pass


@flaky
Expand Down Expand Up @@ -77,11 +85,6 @@ def test_list_zones(client, zone):
assert TEST_ZONE_NAME in zones


@flaky
def test_delete_zone(client, zone):
main.delete_zone(PROJECT, TEST_ZONE_NAME)


@flaky
def test_list_resource_records(client, zone):
records = main.list_resource_records(PROJECT, TEST_ZONE_NAME)
Expand All @@ -94,3 +97,8 @@ def test_list_changes(client, zone):
changes = main.list_changes(PROJECT, TEST_ZONE_NAME)

assert changes


@flaky
def test_delete_zone(client, zone):
main.delete_zone(PROJECT, TEST_ZONE_NAME)