Ejemplo n.º 1
0
 def test_notifier(self):
     notifier = Notifier()
     notifier.add_observer(self.callback_func, NTFY_TORRENTS,
                           [NTFY_STARTED])
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     notifier.remove_observer(self.callback_func)
     return self.test_deferred
Ejemplo n.º 2
0
 def test_notifier_cache(self):
     notifier = Notifier()
     notifier.add_observer(self.cache_callback_func,
                           NTFY_TORRENTS, [NTFY_STARTED],
                           cache=0.1)
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     return self.test_deferred
Ejemplo n.º 3
0
 def test_notifier_cache_remove_observers(self):
     notifier = Notifier()
     notifier.add_observer(self.cache_callback_func,
                           NTFY_TORRENTS, [NTFY_STARTED],
                           cache=10)
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     notifier.remove_observers()
     self.assertEqual(len(notifier.observertimers), 0)
Ejemplo n.º 4
0
 def test_notifier_wrong_changetype(self):
     notifier = Notifier()
     notifier.add_observer(self.callback_func, NTFY_TORRENTS,
                           [NTFY_STARTED])
     notifier.notify(NTFY_TORRENTS, NTFY_FINISHED, None)
     self.assertFalse(self.called_callback)
Ejemplo n.º 5
0
 def test_notifier_no_observers(self):
     notifier = Notifier()
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     self.assertFalse(self.called_callback)
Ejemplo n.º 6
0
 def test_notifier_cache_remove_observers(self):
     notifier = Notifier()
     notifier.add_observer(self.cache_callback_func, NTFY_TORRENTS, [NTFY_STARTED], cache=10)
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     notifier.remove_observers()
     self.assertEqual(len(notifier.observertimers), 0)
Ejemplo n.º 7
0
 def test_notifier_cache_notify_twice(self):
     notifier = Notifier()
     notifier.add_observer(self.cache_callback_func, NTFY_TORRENTS, [NTFY_STARTED], cache=0.1)
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     return self.test_deferred
Ejemplo n.º 8
0
 def test_notifier_wrong_changetype(self):
     notifier = Notifier()
     notifier.add_observer(self.callback_func, NTFY_TORRENTS, [NTFY_STARTED])
     notifier.notify(NTFY_TORRENTS, NTFY_FINISHED, None)
     self.assertFalse(self.called_callback)
Ejemplo n.º 9
0
 def test_notifier_no_observers(self):
     notifier = Notifier()
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     self.assertFalse(self.called_callback)
Ejemplo n.º 10
0
 def test_notifier(self):
     notifier = Notifier()
     notifier.add_observer(self.callback_func, NTFY_TORRENTS, [NTFY_STARTED])
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     notifier.remove_observer(self.callback_func)
     return self.test_deferred