How to use the spidermon.contrib.scrapy.runners.SpiderMonitorRunner function in spidermon

To help you get started, we’ve selected a few spidermon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapinghub / spidermon / tests / contrib / scrapy / test_item_validation_monitor.py View on Github external
def make_data(settings):
    crawler = get_crawler(settings_dict=settings)
    spider = Spider.from_crawler(crawler, "example.com")
    return {
        "stats": crawler.stats.get_stats(),
        "crawler": crawler,
        "spider": spider,
        "runner": SpiderMonitorRunner(spider=spider),
        "job": None,
    }
github scrapinghub / spidermon / tests / contrib / scrapy / test_extensions.py View on Github external
from __future__ import absolute_import
from functools import partial
from unittest import TestCase

from scrapy.utils.test import get_crawler
from scrapy import Spider

from spidermon.contrib.scrapy.extensions import Spidermon
from spidermon.contrib.scrapy.runners import SpiderMonitorRunner


class TestSpiderMonitorRunner(SpiderMonitorRunner):
    __test__ = False

    def run_monitors(self):
        self.result.next_step()
        res = self.suite.run(self.result)
        raise AssertionError((res.failures, res.errors))


def _test_run_suites(self, spider, suites):
    data = self._generate_data_for_spider(spider)
    for suite in suites:
        runner = TestSpiderMonitorRunner(spider=spider)
        runner.run(suite, **data)


class TestData(object):
github scrapinghub / spidermon / tests / test_monitors.py View on Github external
def _make_data(settings=None):
        crawler = Crawler(Spider, settings=settings)
        spider = Spider("dummy")
        return {
            "stats": crawler.stats.get_stats(),
            "crawler": crawler,
            "spider": spider,
            "runner": SpiderMonitorRunner(spider=spider),
            "job": None,
        }
github scrapinghub / spidermon / spidermon / contrib / scrapy / extensions.py View on Github external
def _run_suites(self, spider, suites):
        data = self._generate_data_for_spider(spider)
        for suite in suites:
            runner = SpiderMonitorRunner(spider=spider)
            runner.run(suite, **data)