Skip to content

Commit

Permalink
[cli] migrate delete command to google-cloud-pubsub 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fallonchen committed Dec 15, 2020
1 parent aa57000 commit 3c955c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cli/src/klio_cli/commands/job/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def _delete_subscriptions(self, subscriptions):
for subscription in subscriptions:
logging.info("Deleting subscription {}".format(subscription))
try:
client.delete_subscription(subscription)
client.delete_subscription(
request={"subscription": subscription}
)
except Exception:
logging.error(
"Failed to delete subscription {}".format(subscription),
Expand All @@ -118,7 +120,7 @@ def _delete_topics(self, topics):
for topic in topics:
logging.info("Deleting topic {}".format(topic))
try:
client.delete_topic(topic)
client.delete_topic(request={"topic": topic})
except Exception:
logging.error(
"Failed to delete topic {}".format(topic), exc_info=True
Expand Down
12 changes: 10 additions & 2 deletions cli/tests/commands/job/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ def test_delete_subscription(
mock_subscriber.return_value.delete_subscription.side_effect = effect
delete_job_inst._delete_subscriptions(["a", "b", "c"])
mock_subscriber.return_value.delete_subscription.assert_has_calls(
[mocker.call("a"), mocker.call("b"), mocker.call("c")]
[
mocker.call(request={"subscription": "a"}),
mocker.call(request={"subscription": "b"}),
mocker.call(request={"subscription": "c"}),
]
)
assert 3 == mock_subscriber.return_value.delete_subscription.call_count
assert record_count == len(caplog.records)
Expand All @@ -220,7 +224,11 @@ def test_delete_topic(
mock_publisher.return_value.delete_topic.side_effect = effect
delete_job_inst._delete_topics(["a", "b", "c"])
mock_publisher.return_value.delete_topic.assert_has_calls(
[mocker.call("a"), mocker.call("b"), mocker.call("c")]
[
mocker.call(request={"topic": "a"}),
mocker.call(request={"topic": "b"}),
mocker.call(request={"topic": "c"}),
]
)
assert 3 == mock_publisher.return_value.delete_topic.call_count
assert record_count == len(caplog.records)
Expand Down

0 comments on commit 3c955c0

Please sign in to comment.