Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

from twisted.trial import unittest 

 

import deluge.component as component 

from deluge.core.core import Core 

 

 

class AlertManagerTestCase(unittest.TestCase): 

    def setUp(self):  # NOQA 

        self.core = Core() 

 

        self.am = component.get("AlertManager") 

        component.start(["AlertManager"]) 

 

    def tearDown(self):  # NOQA 

        def on_shutdown(result): 

            component._ComponentRegistry.components = {} 

            del self.am 

            del self.core 

 

        return component.shutdown().addCallback(on_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"], [])