def test_should_raise_scrapingerror_when_response_other_than_ok(self, _):
        url = 'http://something-else.sg/'
        json = {'something': 'fluffy'}

        with patch('requests.post', return_value=FakeResponse(404, json)):
            try:
                rescrape_url(url)
            except ScrapingError as exc:
                self.assertIn(url, exc.msg)
                self.assertEqual(exc.json, json)
            else:
                self.fail("Should've raised ScrapingError")
 def test_should_return_true_when_all_went_okay(self, _):
     self.assertTrue(rescrape_url('http://something-else.sg/'))
示例#3
0
 def scrape(self, obj):
     # Tell facebook to crawl the URL so it both has the data already on
     # first share and we clear all of those debug ones.
     return rescrape_url(urlparse.urljoin(self.url, obj.get_absolute_url()))