Esempio n. 1
0
class TextParserTestCase(BaseOEmbedTestCase):
    def setUp(self):
        self.parser = TextParser()
        super(TextParserTestCase, self).setUp()
    
    def test_basic_handling(self):
        parsed = self.parser.parse(self.category_url)
        self.assertEqual(parsed, self.category_embed)
    
    def test_inline_link_handling(self):
        parsed = self.parser.parse('Testing %s' % self.category_url)
        self.assertEqual(parsed, 'Testing <a href="http://example.com/testapp/category/1/">Category 1</a>')
    
    def test_block_handling(self):
        parsed = self.parser.parse('Testing %(url)s\n%(url)s' % ({'url': self.category_url}))
        self.assertEqual(parsed, 'Testing <a href="http://example.com/testapp/category/1/">Category 1</a>\n%s' % self.category_embed)

    def test_extraction(self):
        extracted = self.parser.extract_urls('Testing %s wha?' % self.category_url)
        self.assertEqual(extracted, set([self.category_url]))
Esempio n. 2
0
 def setUp(self):
     self.parser = TextParser()
     super(TextParserTestCase, self).setUp()