Esempio n. 1
0
    def test_multiple_formatters(self):
        self.staff

        messages = (
            ('[left][url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;"><a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'),
            ('[left]@thoas[/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a></div>'),
            ('[left]@thoas [url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a> <a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'),
        )

        for bbcode, result in messages:
            mark = markup(bbcode, obj=self.post)

            self.assertHTMLEqual(mark, result)
Esempio n. 2
0
    def test_processors(self):
        self.user
        self.staff

        self.post = Post(topic=self.topic, user=self.user, body='@thoas is right!')
        processor = MentionProcessor(self.post.body, obj=self.post)

        self.assertEqual(processor.render(), u'[mention=%d]thoas[/mention] is right!' % self.staff.pk)

        self.post.save()

        body = markup(self.post.body, obj=self.post)

        self.assertEqual(body, '@<a class="mention" href="/users/thoas/">thoas</a> is right!')

        self.assertEqual(Mention.objects.filter(post=self.post,
                                                from_user=self.post.user,
                                                to_user=self.staff).count(), 1)
Esempio n. 3
0
    def test_processors(self):
        self.user
        self.staff

        self.post = Post(topic=self.topic, user=self.user, body='@thoas is right!')
        processor = MentionProcessor(self.post.body, obj=self.post)

        self.assertEqual(processor.render(), u'[mention=%d]thoas[/mention] is right!' % self.staff.pk)

        self.post.save()

        body = markup(self.post.body, obj=self.post)

        self.assertEqual(body, '@<a class="mention" href="/users/thoas/">thoas</a> is right!')

        self.assertEqual(Mention.objects.filter(post=self.post,
                                                from_user=self.post.user,
                                                to_user=self.staff).count(), 1)
Esempio n. 4
0
    def test_multiple_formatters(self):
        self.staff
        self.create_smilies()

        messages = (
            ('[left][url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;"><a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'),
            ('[left]@thoas[/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a></div>'),
            ('[left]@thoas [url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a> <a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'),
            ('[center]this is a smiiiile! :D[/center]',
             u'<div style="text-align: center;">this is a smiiiile! <img src="pybb/smilies/lol.png" alt=":D" class="smiley" title="lol"></div>'),
        )

        for bbcode, result in messages:
            mark = markup(bbcode, obj=self.post)

            self.assertEqual(mark, result)
Esempio n. 5
0
    def test_multiple_formatters(self):
        self.staff

        messages = (
            ('[left][url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;"><a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'
             ),
            ('[left]@thoas[/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a></div>'
             ),
            ('[left]@thoas [url url="http://ulule.com" title="Ulule"][img alt="Ulule" class="link"]http://ulule.com/logo.png[/img][/url][/left]',
             u'<div style="text-align: left;">@<a class="mention" href="/users/thoas/">thoas</a> <a rel="nofollow" title="Ulule" target="_blank" href="http://ulule.com"><img src="http://ulule.com/logo.png" alt="Ulule" class="link"></a></div>'
             ),
        )

        for bbcode, result in messages:
            mark = markup(bbcode, obj=self.post)

            self.assertHTMLEqual(mark, result)