Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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
]
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
# ----------------------------------
# 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):
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):
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):
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]
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)
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
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]