Skip to content

Commit

Permalink
Handle delete Not Found exceptions if needed (#1778)
Browse files Browse the repository at this point in the history
* Handle delete Not Found exceptions if needed

* Update main_test.py
  • Loading branch information
engelke authored Oct 19, 2018
1 parent 293e10c commit a971361
Showing 1 changed file with 15 additions and 7 deletions.
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)

0 comments on commit a971361

Please sign in to comment.