Skip to content

Commit

Permalink
Reverted two tuple changes
Browse files Browse the repository at this point in the history
  • Loading branch information
k-macmillan committed Oct 30, 2024
1 parent 4b8f07e commit 954b916
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@
DELIVERY_STATUS_CALLBACK_TYPE = 'delivery_status'
COMPLAINT_CALLBACK_TYPE = 'complaint'
INBOUND_SMS_CALLBACK_TYPE = 'inbound_sms'
SERVICE_CALLBACK_TYPES = (DELIVERY_STATUS_CALLBACK_TYPE, COMPLAINT_CALLBACK_TYPE, INBOUND_SMS_CALLBACK_TYPE)
# list for backwards compatibility
SERVICE_CALLBACK_TYPES = [DELIVERY_STATUS_CALLBACK_TYPE, COMPLAINT_CALLBACK_TYPE, INBOUND_SMS_CALLBACK_TYPE]
WEBHOOK_CHANNEL_TYPE = 'webhook'
QUEUE_CHANNEL_TYPE = 'queue'
CALLBACK_CHANNEL_TYPES = (WEBHOOK_CHANNEL_TYPE, QUEUE_CHANNEL_TYPE)
CALLBACK_CHANNEL_TYPES = [WEBHOOK_CHANNEL_TYPE, QUEUE_CHANNEL_TYPE]

# Branding
BRANDING_ORG = 'org'
Expand Down
6 changes: 2 additions & 4 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,11 @@ def validate_schema(
):
if 'callback_type' in data and 'notification_statuses' in data:
if data['callback_type'] != DELIVERY_STATUS_CALLBACK_TYPE and data['notification_statuses'] is not None:
raise ValidationError(
f"Callback type {list(data['callback_type'])} should not have notification statuses"
)
raise ValidationError(f"Callback type {data['callback_type']} should not have notification statuses")

if 'callback_channel' in data and 'bearer_token' not in data:
if data['callback_channel'] == 'webhook':
raise ValidationError(f"Callback channel {list(data['callback_channel'])} should have bearer_token")
raise ValidationError(f"Callback channel {data['callback_channel']} should have bearer_token")

@validates('callback_channel')
def validate_callback_channel(
Expand Down
2 changes: 1 addition & 1 deletion tests/app/service/test_callback_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_create_service_callback_returns_400_for_invalid_callback_channel(self,
assert resp_json['errors'][0]['error'] == 'ValidationError'
assert (
resp_json['errors'][0]['message'] == f"callback_channel {data['callback_channel']} is not one of "
f"(webhook, queue)"
f"[webhook, queue]"
)

def test_users_cannot_create_service_callbacks_with_queue_channel(self, client, sample_service):
Expand Down

0 comments on commit 954b916

Please sign in to comment.