Skip to content

Instantly share code, notes, and snippets.

@rennerocha
Last active May 20, 2020 13:49
Show Gist options
  • Save rennerocha/e291570ed4a88db8820923f801012371 to your computer and use it in GitHub Desktop.
Save rennerocha/e291570ed4a88db8820923f801012371 to your computer and use it in GitHub Desktop.
from spidermon import Monitor, MonitorSuite
from spidermon.core.suites import MonitorSuite
from spidermon.runners import TextMonitorRunner
from spidermon.core.actions import Action
class StandaloneMonitor(Monitor):
def test_number_of_errors(self):
num_errors = self.data["num_errors"]
self.assertLessEqual(num_errors, 10, msg="Many errors!")
class StandaloneAction(Action):
def run_action(self):
print("RUNNING ACTION AFTER MONITOR FAILURE:")
print(self.result)
class StandaloneMonitorSuite(MonitorSuite):
monitors = [StandaloneMonitor, ]
monitors_failed_actions = [StandaloneAction]
runner = TextMonitorRunner()
runner.run(StandaloneMonitorSuite(), **{"num_errors": 50})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment