Ejemplo n.º 1
0
    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())
Ejemplo n.º 2
0
    def test_mention_invalid(self):
        sender_user_profile = get_user_profile_by_email("*****@*****.**")
        msg = Message(sender=sender_user_profile, sending_client=get_client("test"))

        content = "Hey @**Nonexistent User**"
        self.assertEqual(msg.render_markdown(content),
                         '<p>Hey @<strong>Nonexistent User</strong></p>')
        self.assertEqual(msg.mentions_user_ids, set())
Ejemplo n.º 3
0
    def test_mention_everyone(self):
        user_profile = get_user_profile_by_email("*****@*****.**")
        msg = Message(sender=user_profile, sending_client=get_client("test"))

        content = "@everyone test"
        self.assertEqual(msg.render_markdown(content),
                         '<p><span class="user-mention" data-user-email="*">@everyone</span> test</p>')
        self.assertTrue(msg.mentions_wildcard)
Ejemplo n.º 4
0
    def test_mention_shortname(self):
        sender_user_profile = get_user_profile_by_email("*****@*****.**")
        user_profile = get_user_profile_by_email("*****@*****.**")
        msg = Message(sender=sender_user_profile, sending_client=get_client("test"))

        content = "@**hamlet**"
        self.assertEqual(msg.render_markdown(content),
                         '<p><span class="user-mention" data-user-email="*****@*****.**">@King Hamlet</span></p>')
        self.assertEqual(msg.mentions_user_ids, set([user_profile.id]))
Ejemplo n.º 5
0
    def test_mention_multiple(self):
        sender_user_profile = get_user_profile_by_email("*****@*****.**")
        hamlet = get_user_profile_by_email("*****@*****.**")
        cordelia = get_user_profile_by_email("*****@*****.**")
        msg = Message(sender=sender_user_profile, sending_client=get_client("test"))

        content = "@**King Hamlet** and @**cordelia**, check this out"
        self.assertEqual(msg.render_markdown(content),
                         '<p>'
                         '<span class="user-mention" '
                         'data-user-email="*****@*****.**">@King Hamlet</span> and '
                         '<span class="user-mention" '
                         'data-user-email="*****@*****.**">@Cordelia Lear</span>, '
                         'check this out</p>')
        self.assertEqual(msg.mentions_user_ids, set([hamlet.id, cordelia.id]))