How to use the spidermon.MonitorSuite 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 / fixtures / levels.py View on Github external
# Suites
# ----------------------------------
class Suites:
    class NoLevelSuite(MonitorSuite):
        pass

    @monitors.level.high
    class HighLevelSuite(MonitorSuite):
        pass

    @monitors.level.normal
    class NormalLevelSuite(MonitorSuite):
        pass

    @monitors.level.low
    class LowLevelSuite(MonitorSuite):
        pass
github scrapinghub / spidermon / tests / fixtures / names.py View on Github external
]


class ChildUnnamedSuite(BaseChildSuite):
    pass


@monitors.name("The Child Suite")
class ChildNamedSuite(BaseChildSuite):
    pass


# ----------------------------------
# Top Suites
# ----------------------------------
class BaseTopSuite(MonitorSuite):
    monitors = [
        ChildUnnamedSuite,
        ChildNamedSuite,
        ("Instance Suite Name", ChildUnnamedSuite),
        ("Instance Suite Name", ChildNamedSuite),
    ]


class UnnamedTopSuite(BaseTopSuite):
    pass


@monitors.name("The Top Suite")
class NamedTopSuite(BaseTopSuite):
    pass
github scrapinghub / spidermon / tests / fixtures / descriptions.py View on Github external
# ----------------------------------
# Suites
# ----------------------------------
class NotDescriptedSuite(MonitorSuite):
    pass


class DocstringDescriptedSuite(MonitorSuite):
    """docstring suite description"""

    pass


@monitors.description("decorator suite description")
class DescoratedDescriptedSuite(MonitorSuite):
    pass


@monitors.description("decorator suite description")
class DescoratedDescriptedSuite2(MonitorSuite):
    """docstring suite description"""


# ----------------------------------
# Methods
# ----------------------------------
class DescriptedMethodsMonitor(Monitor):
    def test_not_descripted(self):
        pass

    def test_docstring_descripted(self):
github scrapinghub / spidermon / tests / fixtures / suites.py View on Github external
from __future__ import absolute_import
from spidermon import MonitorSuite


from .cases import *


class EmptySuite(MonitorSuite):
    pass


class Suite01(MonitorSuite):
    monitors = [Monitor01]


class Suite02(MonitorSuite):
    monitors = [Suite01, Monitor02]


class Suite03(MonitorSuite):
    monitors = [Suite01, Suite02]


class Suite04(MonitorSuite):
github scrapinghub / spidermon / tests / fixtures / descriptions.py View on Github external
pass


class DocstringDescriptedSuite(MonitorSuite):
    """docstring suite description"""

    pass


@monitors.description("decorator suite description")
class DescoratedDescriptedSuite(MonitorSuite):
    pass


@monitors.description("decorator suite description")
class DescoratedDescriptedSuite2(MonitorSuite):
    """docstring suite description"""


# ----------------------------------
# Methods
# ----------------------------------
class DescriptedMethodsMonitor(Monitor):
    def test_not_descripted(self):
        pass

    def test_docstring_descripted(self):
        """docstring method description"""
        pass

    @monitors.description("decorator method description")
    def test_decorator_descripted(self):
github scrapinghub / spidermon / tests / fixtures / suites.py View on Github external
pass


class Suite01(MonitorSuite):
    monitors = [Monitor01]


class Suite02(MonitorSuite):
    monitors = [Suite01, Monitor02]


class Suite03(MonitorSuite):
    monitors = [Suite01, Suite02]


class Suite04(MonitorSuite):
    monitors = [Suite01, Suite02, Monitor01, Monitor02]
github scrapinghub / spidermon / spidermon / contrib / scrapy / extensions.py View on Github external
def load_suite(self, suite_to_load):
        try:
            suite_class = load_object(suite_to_load)
        except Exception as e:
            raise e  # TO-DO
        if not issubclass(suite_class, MonitorSuite):
            raise Exception  # TO-DO
        return suite_class(crawler=self.crawler)
github scrapinghub / spidermon / spidermon / contrib / scrapy / extensions.py View on Github external
def load_expression_suite(self, suite_to_load, monitor_class=None):
        if monitor_class:
            monitor_class = load_object(monitor_class)
        else:
            monitor_class = ExpressionsMonitor
        monitor = factory.create_monitor_class_from_dict(
            monitor_dict=suite_to_load, monitor_class=monitor_class
        )
        suite = MonitorSuite(crawler=self.crawler)
        suite.add_monitor(monitor)
        return suite
github okfn-brasil / open-jus / justa / crawler / justa / monitors / distrito_federal.py View on Github external
from spidermon import Monitor, MonitorSuite, monitors


@monitors.name('Distrito Federal')
class DistritoFederalMonitor(Monitor):

    @monitors.name('Minimum number of items')
    def test_minimum_number_of_items(self):
        items_extracted = self.data.stats.get('item_scraped_count', 0)
        self.assertGreaterEqual(items_extracted, 433)


class DistritoFederalMonitorSuite(MonitorSuite):
    monitors = [DistritoFederalMonitor]