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, alert_words) return json_success()
def test_alert_words(self): user_profile = get_user_profile_by_email("*****@*****.**") do_set_alert_words(user_profile, ["ALERTWORD", "scaryword"]) msg = Message(sender=user_profile, sending_client=get_client("test")) content = "We have an ALERTWORD day today!" self.assertEqual(msg.render_markdown(content), "<p>We have an ALERTWORD day today!</p>") self.assertEqual(msg.user_ids_with_alert_words, set([user_profile.id])) msg = Message(sender=user_profile, sending_client=get_client("test")) content = "We have a NOTHINGWORD day today!" self.assertEqual(msg.render_markdown(content), "<p>We have a NOTHINGWORD day today!</p>") self.assertEqual(msg.user_ids_with_alert_words, set())
def set_alert_words(request, user_profile, alert_words=REQ(validator=check_list(check_string), default=[])): do_set_alert_words(user_profile, alert_words) return json_success()