Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b57b562

Browse filesBrowse files
author
Takashi Matsuo
authored
[iot] testing: re-raise the exception (GoogleCloudPlatform#3425)
fixes GoogleCloudPlatform#3424
1 parent d6bf6c0 commit b57b562
Copy full SHA for b57b562

File tree

Expand file treeCollapse file tree

2 files changed

+11
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-9
lines changed

‎iot/api-client/manager/manager.py

Copy file name to clipboardExpand all lines: iot/api-client/manager/manager.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def delete_registry(
247247
return 'Registry deleted'
248248
except HttpError:
249249
print('Error, registry not deleted')
250-
return 'Registry not deleted'
250+
raise
251251
# [END iot_delete_registry]
252252

253253

@@ -391,10 +391,10 @@ def create_registry(
391391
return response
392392
except HttpError:
393393
print('Error, registry not created')
394-
return ""
394+
raise
395395
except AlreadyExists:
396396
print('Error, registry already exists')
397-
return ""
397+
raise
398398
# [END iot_create_registry]
399399

400400

@@ -422,12 +422,12 @@ def open_registry(
422422
# registry_id = 'your-registry-id'
423423
print('Creating registry')
424424

425-
response = create_registry(
426-
service_account_json, project_id, cloud_region,
427-
pubsub_topic, registry_id)
428-
429-
if response == '':
430-
# Device registry already exists
425+
try:
426+
response = create_registry(
427+
service_account_json, project_id, cloud_region,
428+
pubsub_topic, registry_id)
429+
except AlreadyExists:
430+
# Device registry already exists. We just re-use the existing one.
431431
print(
432432
'Registry {} already exists - looking it up instead.'.format(
433433
registry_id))

‎iot/api-client/manager/manager_test.py

Copy file name to clipboardExpand all lines: iot/api-client/manager/manager_test.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
3939

4040
pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)
41+
42+
# This format is used in the `clean_up_registries()` below.
4143
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))
4244

4345

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.