push_notifications: Move "push" part of URLs to callers.

This will make it possible for us to use this library for endpoints
not directly related to push notifications.
This commit is contained in:
Tim Abbott 2019-01-30 16:36:18 -08:00
parent 4fab08172b
commit 2d11e163dd
3 changed files with 5 additions and 5 deletions

View File

@ -274,7 +274,7 @@ def send_notifications_to_bouncer(user_profile_id: int,
'gcm_payload': gcm_payload,
}
# Calls zilencer.views.remote_server_notify_push
send_json_to_push_bouncer('POST', 'notify', post_data)
send_json_to_push_bouncer('POST', 'push/notify', post_data)
#
# Managing device tokens
@ -308,7 +308,7 @@ def add_push_device_token(user_profile: UserProfile,
logger.info("Sending new push device to bouncer: %r", post_data)
# Calls zilencer.views.register_remote_push_device
send_to_push_bouncer('POST', 'register', post_data)
send_to_push_bouncer('POST', 'push/register', post_data)
return
try:
@ -336,7 +336,7 @@ def remove_push_device_token(user_profile: UserProfile, token_str: bytes, kind:
'token_kind': kind,
}
# Calls zilencer.views.unregister_remote_push_device
send_to_push_bouncer("POST", "unregister", post_data)
send_to_push_bouncer("POST", "push/unregister", post_data)
return
try:

View File

@ -32,7 +32,7 @@ def send_to_push_bouncer(method: str,
"""
url = urllib.parse.urljoin(settings.PUSH_NOTIFICATION_BOUNCER_URL,
'/api/v1/remotes/push/' + endpoint)
'/api/v1/remotes/' + endpoint)
api_auth = requests.auth.HTTPBasicAuth(settings.ZULIP_ORG_ID,
settings.ZULIP_ORG_KEY)

View File

@ -1116,7 +1116,7 @@ class TestSendNotificationsToBouncer(ZulipTestCase):
'gcm_payload': {'gcm': True},
}
mock_send.assert_called_with('POST',
'notify',
'push/notify',
ujson.dumps(post_data),
extra_headers={'Content-type':
'application/json'})