def __activate__(self, context): response = context["response"] log = context["log"] writer = response.getPrintWriter("text/plain; charset=UTF-8") try: writer.println("Alert script has been started") alerts = NewAlerts() alerts.run(context) writer.println("Alert script has completed") except Exception, e: writer.println("The alert system had a problem - check logs") log.error("Exception in alerts code: %s" % (e.message)) raise
def main(config): config = getConfig(config) alert = NewAlerts() alert.log = Log() alert.run(config)
def test_run_alert(self): config = self.__getConfig("system-config-new.json") alert = NewAlerts() alert.log = Log() self.assertTrue(alert.run(config))
def test_no_alert_config(self): # Tests that we handle situations where the config has no alerts config config = self.__getConfig("system-config.1.json") alert = NewAlerts() self.assertFalse(alert.run(config))
def test_incorrect_config(self): config = self.__getConfig("system-config.2.json") alert = NewAlerts() self.assertRaises(AlertException, alert.run, config)
def test_no_alert_config(self): #Tests that we handle situations where the config has no alerts config config = self.__getConfig("system-config.1.json") alert = NewAlerts() self.assertFalse(alert.run(config))
def test_no_config(self): #Tests that we handle situations where the config is missing redbox.version.string config = self.__getConfig("system-config.0.json") alert = alert = NewAlerts() self.assertRaises(AlertException, alert.run, config)