コード例 #1
0
ファイル: spider_tests.py プロジェクト: abyu/sitecrawler
    def test_parse_all_links_using_links_tag_parser_in_page_for_the_given_url(
            self):
        page_url = "http://asamplepage.com"
        html_content = "An html page with links"
        page_links = [
            Link(url="/about",
                 label="A link",
                 parent_url="http://asamplepage.com"),
            Link("http://aurl.com",
                 "A link",
                 parent_url="http://asamplepage.com")
        ]
        mock_client = mock()
        mock_parser = mock()
        when(mock_client).get_html_page(page_url).thenReturn(html_content)
        when(mock_parser).parse(ANY(LinkTagParser),
                                eq(html_content)).thenReturn(page_links)
        scraper = LinkScraper(mock_client, mock_parser)

        links = scraper.scrape_links(page_url)

        self.assertEquals(2, len(links))
        self.assertCountEqual(page_links, links)
コード例 #2
0
 def testShouldNotSatisfyIfArgDoesNotMatchGivenValue(self):
     self.assertFalse(eq("foo").matches("bar"))
コード例 #3
0
 def testShouldSatisfyIfArgMatchesGivenValue(self):
     self.assertTrue(eq("foo").matches("foo"))