deluge/deluge/tests/test_alertmanager.py
bendikro 70d8b65f0a [WebUi] [Core] Fixes to plugin handling and WebUi plugin + tests
This should fix problems with errors occuring when failing to
enable plugins. Errors in plugin handling are handled better
and properly logged.

WebUI plugin in particular had issues when being enabled and disabled
multiple times because it was trying to create DelugeWeb component
each time it was enabled. If deluge-web is already listening on
the same port, enabling the WebUI plugin will fail, and the checkbox
will not be checked.

There are still some issues when enabling/disabling plugins by
clicking fast multiple times on the checkbox.
2016-04-18 15:49:30 +01:00

38 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
import deluge.component as component
from deluge.core.core import Core
from .basetest import BaseTestCase
class AlertManagerTestCase(BaseTestCase):
def set_up(self):
self.core = Core()
self.am = component.get("AlertManager")
return component.start(["AlertManager"])
def tear_down(self):
return component.shutdown()
def test_register_handler(self):
def handler(alert):
return
self.am.register_handler("dummy_alert", handler)
self.assertEquals(self.am.handlers["dummy_alert"], [handler])
def test_deregister_handler(self):
def handler(alert):
return
self.am.register_handler("dummy_alert", handler)
self.am.deregister_handler(handler)
self.assertEquals(self.am.handlers["dummy_alert"], [])