Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
[iot] testing: re-raise the exception [(#3425)](GoogleCloudPlatform/p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo authored Apr 17, 2020
1 parent 393be3e commit 3752102
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions samples/api-client/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def delete_registry(
return 'Registry deleted'
except HttpError:
print('Error, registry not deleted')
return 'Registry not deleted'
raise
# [END iot_delete_registry]


Expand Down Expand Up @@ -391,10 +391,10 @@ def create_registry(
return response
except HttpError:
print('Error, registry not created')
return ""
raise
except AlreadyExists:
print('Error, registry already exists')
return ""
raise
# [END iot_create_registry]


Expand Down Expand Up @@ -422,12 +422,12 @@ def open_registry(
# registry_id = 'your-registry-id'
print('Creating registry')

response = create_registry(
service_account_json, project_id, cloud_region,
pubsub_topic, registry_id)

if response == '':
# Device registry already exists
try:
response = create_registry(
service_account_json, project_id, cloud_region,
pubsub_topic, registry_id)
except AlreadyExists:
# Device registry already exists. We just re-use the existing one.
print(
'Registry {} already exists - looking it up instead.'.format(
registry_id))
Expand Down
2 changes: 2 additions & 0 deletions samples/api-client/manager/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']

pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)

# This format is used in the `clean_up_registries()` below.
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))


Expand Down

0 comments on commit 3752102

Please sign in to comment.