Exemplo n.º 1
0
 def test_task_clone_grab_config_and_url(self):
     g = build_grab()
     g.setup(url='http://foo.com/')
     task = Task('foo', grab=g)
     task2 = task.clone(url='http://bar.com/')
     self.assertEqual(task2.url, 'http://bar.com/')
     self.assertEqual(task2.grab_config['url'], 'http://bar.com/')
Exemplo n.º 2
0
 def test_task_clone_grab_config_and_url(self):
     grab = build_grab()
     grab.setup(url='http://foo.com/')
     task = Task('foo', grab=grab)
     task2 = task.clone(url='http://bar.com/')
     self.assertEqual(task2.url, 'http://bar.com/')
     self.assertEqual(task2.grab_config['url'], 'http://bar.com/')
Exemplo n.º 3
0
    def test_task_clone(self):
        bot = build_spider(SimpleSpider, )
        bot.setup_queue()

        task = Task('baz', url='http://xxx.com')
        bot.add_task(task.clone())

        # Pass grab to clone
        task = Task('baz', url='http://xxx.com')
        grab = Grab()
        grab.setup(url='zzz')
        bot.add_task(task.clone(grab=grab))

        # Pass grab_config to clone
        task = Task('baz', url='http://xxx.com')
        grab = Grab()
        grab.setup(url='zzz')
        bot.add_task(task.clone(grab_config=grab.config))
Exemplo n.º 4
0
    def test_task_clone(self):
        bot = build_spider(SimpleSpider, )
        bot.setup_queue()

        task = Task('baz', url='xxx')
        bot.add_task(task.clone())

        # Pass grab to clone
        task = Task('baz', url='xxx')
        g = Grab()
        g.setup(url='zzz')
        bot.add_task(task.clone(grab=g))

        # Pass grab_config to clone
        task = Task('baz', url='xxx')
        g = Grab()
        g.setup(url='zzz')
        bot.add_task(task.clone(grab_config=g.config))
Exemplo n.º 5
0
    def test_task_clone(self):
        bot = SimpleSpider()
        bot.setup_queue()

        task = Task('baz', url='xxx')
        bot.add_task(task.clone())

        # Pass grab to clone
        task = Task('baz', url='xxx')
        g = Grab()
        g.setup(url='zzz')
        bot.add_task(task.clone(grab=g))

        # Pass grab_config to clone
        task = Task('baz', url='xxx')
        g = Grab()
        g.setup(url='zzz')
        bot.add_task(task.clone(grab_config=g.config))
Exemplo n.º 6
0
    def test_task_useragent(self):
        bot = build_spider(SimpleSpider, )
        bot.setup_queue()

        grab = Grab()
        grab.setup(url=self.server.get_url())
        grab.setup(user_agent='Foo')

        task = Task('baz', grab=grab)
        bot.add_task(task.clone())
        bot.run()
        self.assertEqual(self.server.request['headers']['User-Agent'], 'Foo')
Exemplo n.º 7
0
    def test_task_useragent(self):
        bot = build_spider(SimpleSpider, )
        bot.setup_queue()

        g = Grab()
        g.setup(url=self.server.get_url())
        g.setup(user_agent='Foo')

        task = Task('baz', grab=g)
        bot.add_task(task.clone())
        bot.run()
        self.assertEqual(self.server.request['headers']['User-Agent'], 'Foo')
Exemplo n.º 8
0
    def test_task_useragent(self):
        bot = SimpleSpider()
        bot.setup_queue()

        g = Grab()
        g.setup(url=SERVER.BASE_URL)
        g.setup(user_agent='Foo')

        task = Task('baz', grab=g)
        bot.add_task(task.clone())
        bot.run()
        self.assertEqual(SERVER.REQUEST['headers']['User-Agent'], 'Foo')
Exemplo n.º 9
0
    def test_task_useragent(self):
        bot = SimpleSpider()
        bot.setup_queue()

        g = Grab()
        g.setup(url=SERVER.BASE_URL)
        g.setup(user_agent='Foo')

        task = Task('baz', grab=g)
        bot.add_task(task.clone())
        bot.run()
        self.assertEqual(SERVER.REQUEST['headers']['User-Agent'], 'Foo')
Exemplo n.º 10
0
 def test_task_clone_with_url_param(self):
     task = Task('baz', url='http://example.com/path')
     task2 = task.clone(url='http://example.com/new')
     self.assertEqual(task2.name, 'baz')
     self.assertEqual(task2.url, 'http://example.com/new')
Exemplo n.º 11
0
 def test_task_clone_kwargs(self):
     grab = build_grab()
     grab.setup(url='http://foo.com/')
     task = Task('foo', grab=grab, cache_timeout=1)
     task2 = task.clone(cache_timeout=2)
     self.assertEqual(2, task2.cache_timeout)
Exemplo n.º 12
0
 def test_task_clone_with_url_param(self):
     task = Task('baz', url='xxx')
     task.clone(url='http://yandex.ru/')
Exemplo n.º 13
0
 def test_task_clone_kwargs(self):
     g = build_grab()
     g.setup(url='http://foo.com/')
     task = Task('foo', grab=g, cache_timeout=1)
     task2 = task.clone(cache_timeout=2)
     self.assertEqual(2, task2.cache_timeout)
Exemplo n.º 14
0
 def test_task_clone_kwargs(self):
     grab = build_grab()
     grab.setup(url='http://foo.com/')
     task = Task('foo', grab=grab, foo=1)
     task2 = task.clone(foo=2)
     self.assertEqual(2, task2.foo) # pylint: disable=no-member
Exemplo n.º 15
0
 def test_task_clone_with_url_param(self):
     task = Task('baz', url='xxx')
     task.clone(url='http://yandex.ru/')