1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-24 07:24:12 +00:00
scrapy/tests/test_spidermiddleware_urllength.py

22 lines
678 B
Python
Raw Normal View History

2009-09-07 11:14:47 -03:00
from unittest import TestCase
from scrapy.spidermiddlewares.urllength import UrlLengthMiddleware
2009-09-07 11:14:47 -03:00
from scrapy.http import Response, Request
from scrapy.spiders import Spider
2009-09-07 11:14:47 -03:00
class TestUrlLengthMiddleware(TestCase):
def test_process_spider_output(self):
res = Response('http://scrapytest.org')
short_url_req = Request('http://scrapytest.org/')
long_url_req = Request('http://scrapytest.org/this_is_a_long_url')
reqs = [short_url_req, long_url_req]
2009-09-07 11:14:47 -03:00
mw = UrlLengthMiddleware(maxlength=25)
spider = Spider('foo')
out = list(mw.process_spider_output(res, reqs, spider))
self.assertEqual(out, [short_url_req])
2009-09-07 11:14:47 -03:00