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