Пример #1
0
    def test_find_link(self):
        requests.get = Mock()

        class Temp(object):
            text = """
              <html><a href= "http://docs.yahoo.co.jp/target"></a></html>
            """
        requests.get.return_value = Temp()
        printer = BrowserPrinter(self.config)

        self.assertEqual([Link('http://docs.yahoo.co.jp/target')], printer.find_link(Link('top')))
Пример #2
0
    def test_crawl(self):
        printer = BrowserPrinter(self.config)
        printer.find_link = MagicMock(return_value=[Link('http://docs.yahoo.co.jp/sample')])

        self.assertEqual([Link('http://docs.yahoo.co.jp/sample')], printer.crawl(Link('http://www.yahoo.co.jp')))