Exemplo n.º 1
0
class HTMLConsumerTestCase(TestCase):
    def setUp(self):
        self.consumer = HTMLConsumer()

    def test_is_hyperlinked(self):
        soup = BeautifulSoup("NOTLINK <a>LINKED</a>")
        nodes = soup.findAll(text=re.compile(r"LINK"))

        self.assertFalse(self.consumer._is_hyperlinked(nodes[0]))
        self.assertTrue(self.consumer._is_hyperlinked(nodes[1]))

    @patch("monocle.consumers.registry")
    def test_devour(self, registry):
        provider = Mock()
        provider.get_resource.return_value = provider
        provider.render.return_value = "RESOURCE"

        registry.match.return_value = provider

        result = self.consumer.devour(HTML_CONTENT)

        self.assertIn("<p>URL content RESOURCE</p>", result)
        self.assertIn("<p>URL content RESOURCE, RESOURCE, and (RESOURCE)</p>", result)
        self.assertIn("<p>Link content <a>http://foo.com</a>", result)
Exemplo n.º 2
0
 def setUp(self):
     self.consumer = HTMLConsumer()