Skip to content

Commit

Permalink
ENH: Raise error if attempting to pull a BigQuery subscription
Browse files Browse the repository at this point in the history
skipci
  • Loading branch information
cortadocodes committed Mar 5, 2024
1 parent b45f07a commit 9c785a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion octue/cloud/pub_sub/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,17 @@ def wait_for_answer(
:return dict: dictionary containing the keys "output_values" and "output_manifest"
"""
if subscription.is_push_subscription:
raise octue.exceptions.PushSubscriptionCannotBePulled(
raise octue.exceptions.NotAPullSubscription(
f"{subscription.path!r} is a push subscription so it cannot be waited on for an answer. Please check "
f"its push endpoint at {subscription.push_endpoint!r}."
)

if subscription.is_bigquery_subscription:
raise octue.exceptions.NotAPullSubscription(
f"{subscription.path!r} is a BigQuery subscription so it cannot be waited on for an answer. Please "
f"check its BigQuery table {subscription.bigquery_table_id!r}."
)

service_name = get_sruid_from_pub_sub_resource_name(subscription.name)

self._message_handler = OrderedMessageHandler(
Expand Down
4 changes: 2 additions & 2 deletions octue/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class CloudStorageBucketNotFound(OctueSDKException):
"""Raise if attempting to access a cloud storage bucket that cannot be found."""


class PushSubscriptionCannotBePulled(OctueSDKException):
"""Raise if attempting to pull a push subscription."""
class NotAPullSubscription(OctueSDKException):
"""Raise if attempting to pull a subscription that's not a pull subscription."""


class ConflictingSubscriptionType(OctueSDKException):
Expand Down
2 changes: 1 addition & 1 deletion tests/cloud/pub_sub/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_error_raised_if_attempting_to_wait_for_answer_from_push_subscription(se

service = Service(backend=BACKEND)

with self.assertRaises(exceptions.PushSubscriptionCannotBePulled):
with self.assertRaises(exceptions.NotAPullSubscription):
service.wait_for_answer(subscription=mock_subscription)

def test_exceptions_in_responder_are_handled_and_sent_to_asker(self):
Expand Down

0 comments on commit 9c785a5

Please sign in to comment.