def test_head_location(self): controller = http_controller_factory(location='Paris') url = URL('http://goog.le') location = url.head_location(controller) controller.head_location.assert_called_once_with('http://goog.le') self.assertEqual('Paris', location)
def test_get_content(self): controller = http_controller_factory(content=b'my content') url = URL('http://google.fr') content = url.get_content(controller, referer='http://epf.fr') controller.get_content.assert_called_once_with('http://google.fr', referer='http://epf.fr') self.assertEqual(b'my content', content)
def test_head_location(self): controller = http_controller_factory(location='Paris') url = URL('http://goog.le') location = url.head_location(controller) controller.head_location.assert_called_once_with( 'http://goog.le') self.assertEqual('Paris', location)
def test_get_content(self): controller = http_controller_factory(content=b'my content') url = URL('http://google.fr') content = url.get_content(controller, referer='http://epf.fr') controller.get_content.assert_called_once_with( 'http://google.fr', referer='http://epf.fr') self.assertEqual(b'my content', content)
def test_download(self): downloaded_file_factory = Mock() controller = http_controller_factory( location='http://google.fr/plouf.doc', content=b'my content', ) downloader = Downloader(controller, downloaded_file_factory, URL) downloader.download('http://yoman.com/plouf') controller.get_content.assert_called_once_with( 'http://yoman.com/plouf', referer='http://google.fr/plouf.doc', ) downloaded_file_factory.assert_called_once_with( b'my content', 'plouf.doc', )