示例#1
0
class TestRequestFactory(unittest.TestCase):
    def setUp(self):
        self.request_factory = RequestFactory()

    @mock.patch('xcrawler.http.requests.request.Request')
    def test_create_request(self, mock_request_class):
        mock_method = "GET"
        mock_url = "http://example.com/path/to/mock_url.html"
        mock_request = mock.create_autospec(Request).return_value
        mock_request_class.return_value = mock_request
        result = self.request_factory.create_request(mock_method, mock_url)
        self.assertEquals(result, mock_request)
示例#2
0
class TestRequestFactory(unittest.TestCase):

    def setUp(self):
        self.request_factory = RequestFactory()

    @mock.patch('xcrawler.http.requests.request.Request')
    def test_create_request(self, mock_request_class):
        mock_method = "GET"
        mock_url = "http://example.com/path/to/mock_url.html"
        mock_request = mock.create_autospec(Request).return_value
        mock_request_class.return_value = mock_request
        result = self.request_factory.create_request(mock_method, mock_url)
        self.assertEquals(result, mock_request)
示例#3
0
文件: page.py 项目: anthrax3/xcrawler
 def __init__(self,
              url,
              page_scraper,
              request_factory=RequestFactory(),
              extractor_factory=ExtractorFactory(),
              url_joiner=UrlJoiner(),
              request_sender=RequestSender(),
              compatibility_factory=CompatibilityFactory()):
     self.url = url
     self.scraper = page_scraper
     self._content = None
     self.extractor = None
     self.request_factory = request_factory
     self.request = self.request_factory.create_request('GET', self.url)
     self.extractor_factory = extractor_factory
     self.url_joiner = url_joiner
     self.request_sender = request_sender
     self.string_converter = compatibility_factory.create_compatible_string_converter(
     )
示例#4
0
 def setUp(self):
     self.request_factory = RequestFactory()
示例#5
0
 def setUp(self):
     self.request_factory = RequestFactory()