urls: Remove the old POST endpoint for alert words.

This commit is contained in:
Alena Volkova
2017-09-25 17:41:41 -04:00
committed by Tim Abbott
parent b17fecbf06
commit ca687e01d7
3 changed files with 2 additions and 24 deletions

View File

@@ -39,7 +39,7 @@ class AlertWordTests(ZulipTestCase):
params = { params = {
'alert_words': ujson.dumps(['milk', 'cookies']) 'alert_words': ujson.dumps(['milk', 'cookies'])
} }
result = self.client_post('/json/users/me/alert_words', params) result = self.client_put('/json/users/me/alert_words', params)
self.assert_json_success(result) self.assert_json_success(result)
user = self.example_user(user_name) user = self.example_user(user_name)
words = user_alert_words(user) words = user_alert_words(user)
@@ -140,20 +140,6 @@ class AlertWordTests(ZulipTestCase):
self.assert_json_success(result) self.assert_json_success(result)
self.assertEqual(result.json()['alert_words'], ['two', 'three']) self.assertEqual(result.json()['alert_words'], ['two', 'three'])
def test_json_list_set(self):
# type: () -> None
self.login(self.example_email("hamlet"))
result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])})
self.assert_json_success(result)
result = self.client_post('/json/users/me/alert_words', {'alert_words': ujson.dumps(['a', 'b', 'c'])})
self.assert_json_success(result)
result = self.client_get('/json/users/me/alert_words')
self.assert_json_success(result)
self.assertEqual(result.json()['alert_words'], ['a', 'b', 'c'])
def message_does_alert(self, user_profile, message): def message_does_alert(self, user_profile, message):
# type: (UserProfile, Text) -> bool # type: (UserProfile, Text) -> bool
"""Send a bunch of messages as othello, so Hamlet is notified""" """Send a bunch of messages as othello, so Hamlet is notified"""

View File

@@ -9,7 +9,7 @@ from zerver.decorator import has_request_variables, REQ
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.validator import check_list, check_string from zerver.lib.validator import check_list, check_string
from zerver.lib.actions import do_add_alert_words, do_remove_alert_words, do_set_alert_words from zerver.lib.actions import do_add_alert_words, do_remove_alert_words
from zerver.lib.alert_words import user_alert_words from zerver.lib.alert_words import user_alert_words
def list_alert_words(request, user_profile): def list_alert_words(request, user_profile):
@@ -21,13 +21,6 @@ def clean_alert_words(alert_words):
alert_words = [w.strip() for w in alert_words] alert_words = [w.strip() for w in alert_words]
return [w for w in alert_words if w != ""] return [w for w in alert_words if w != ""]
@has_request_variables
def set_alert_words(request, user_profile,
alert_words=REQ(validator=check_list(check_string), default=[])):
# type: (HttpRequest, UserProfile, List[Text]) -> HttpResponse
do_set_alert_words(user_profile, clean_alert_words(alert_words))
return json_success()
@has_request_variables @has_request_variables
def add_alert_words(request, user_profile, def add_alert_words(request, user_profile,
alert_words=REQ(validator=check_list(check_string), default=[])): alert_words=REQ(validator=check_list(check_string), default=[])):

View File

@@ -365,7 +365,6 @@ v1_api_and_json_patterns = [
# users/me/alert_words -> zerver.views.alert_words # users/me/alert_words -> zerver.views.alert_words
url(r'^users/me/alert_words$', rest_dispatch, url(r'^users/me/alert_words$', rest_dispatch,
{'GET': 'zerver.views.alert_words.list_alert_words', {'GET': 'zerver.views.alert_words.list_alert_words',
'POST': 'zerver.views.alert_words.set_alert_words',
'PUT': 'zerver.views.alert_words.add_alert_words', 'PUT': 'zerver.views.alert_words.add_alert_words',
'DELETE': 'zerver.views.alert_words.remove_alert_words'}), 'DELETE': 'zerver.views.alert_words.remove_alert_words'}),