Last active
May 20, 2020 13:49
-
-
Save rennerocha/e291570ed4a88db8820923f801012371 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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