Example #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
Example #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
Example #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)
Example #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)
Example #5
0
 def test_notifier_no_observers(self):
     notifier = Notifier()
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     self.assertFalse(self.called_callback)
Example #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)
Example #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
Example #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)
Example #9
0
 def test_notifier_no_observers(self):
     notifier = Notifier()
     notifier.notify(NTFY_TORRENTS, NTFY_STARTED, None)
     self.assertFalse(self.called_callback)
Example #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