How to use the micawber.test_utils.test_pr.parse_text_full function in micawber

To help you get started, we’ve selected a few micawber examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coleifer / micawber / micawber / tests.py View on Github external
def test_urlize_params(self):
        text = 'test http://foo.com/'
        urlize_params = {'target': '_blank', 'rel': 'nofollow'}
        exp = ('test <a rel="nofollow" href="http://foo.com/">'
               'http://foo.com/</a>')

        result = test_pr.parse_text(text, urlize_params=urlize_params)
        self.assertEqual(result, exp)

        result = test_pr.parse_text_full(text, urlize_params=urlize_params)
        self.assertEqual(result, exp)

        result = test_pr.parse_html(text, urlize_params=urlize_params)
        self.assertEqual(result, exp)
github coleifer / micawber / micawber / tests.py View on Github external
def test_urlize(self):
        blank = 'http://fapp.io/foo/'
        blank_e = '<a href="http://fapp.io/foo/">http://fapp.io/foo/</a>'
        for url, expected in self.full_pairs.items():
            expected_inline = self.inline_pairs[url]
            frame = 'test %s\n%s\n%s\nand finally %s'

            test_str = frame % (url, blank, url, blank)

            parsed = test_pr.parse_text(test_str)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank_e, expected, blank_e))

            parsed = test_pr.parse_text(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank, expected, blank))

            parsed = test_pr.parse_text_full(test_str)
            self.assertHTMLEqual(parsed, frame % (expected, blank_e, expected, blank_e))

            parsed = test_pr.parse_text_full(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected, blank, expected, blank))

            parsed = test_pr.parse_html(test_str)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank_e, expected_inline, blank_e))

            parsed = test_pr.parse_html(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank, expected_inline, blank))

            frame = '<p>test %s</p>\n<a href="foo">%s</a>\n<a href="foo2">%s</a>\n<p>and finally %s</p>'

            test_str = frame % (url, blank, url, blank)

            parsed = test_pr.parse_html(test_str)
github coleifer / micawber / micawber / tests.py View on Github external
for url, expected in self.full_pairs.items():
            expected_inline = self.inline_pairs[url]
            frame = 'test %s\n%s\n%s\nand finally %s'

            test_str = frame % (url, blank, url, blank)

            parsed = test_pr.parse_text(test_str)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank_e, expected, blank_e))

            parsed = test_pr.parse_text(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank, expected, blank))

            parsed = test_pr.parse_text_full(test_str)
            self.assertHTMLEqual(parsed, frame % (expected, blank_e, expected, blank_e))

            parsed = test_pr.parse_text_full(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected, blank, expected, blank))

            parsed = test_pr.parse_html(test_str)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank_e, expected_inline, blank_e))

            parsed = test_pr.parse_html(test_str, urlize_all=False)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank, expected_inline, blank))

            frame = '<p>test %s</p>\n<a href="foo">%s</a>\n<a href="foo2">%s</a>\n<p>and finally %s</p>'

            test_str = frame % (url, blank, url, blank)

            parsed = test_pr.parse_html(test_str)
            self.assertHTMLEqual(parsed, frame % (expected_inline, blank, url, blank_e))

            parsed = test_pr.parse_html(test_str, urlize_all=False)
github coleifer / micawber / micawber / tests.py View on Github external
def test_parse_text_full(self):
        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_text_full(url)
            self.assertHTMLEqual(parsed, expected)

        # the parse_text_full will replace even inline content
        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_text_full('this is inline: %s' % url)
            self.assertHTMLEqual(parsed, 'this is inline: %s' % expected)

        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_html('<p>%s</p>' % url)
            self.assertHTMLEqual(parsed, '<p>%s</p>' % expected)
github coleifer / micawber / micawber / tests.py View on Github external
def test_multiline_full(self):
        for url, expected in self.full_pairs.items():
            frame = 'this is inline: %s\n%s\nand yet another %s'

            test_str = frame % (url, url, url)

            parsed = test_pr.parse_text_full(test_str)
            self.assertHTMLEqual(parsed, frame % (expected, expected, expected))
github coleifer / micawber / micawber / tests.py View on Github external
def test_parse_text_full(self):
        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_text_full(url)
            self.assertHTMLEqual(parsed, expected)

        # the parse_text_full will replace even inline content
        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_text_full('this is inline: %s' % url)
            self.assertHTMLEqual(parsed, 'this is inline: %s' % expected)

        for url, expected in self.full_pairs.items():
            parsed = test_pr.parse_html('<p>%s</p>' % url)
            self.assertHTMLEqual(parsed, '<p>%s</p>' % expected)