class ObservableTest(unittest.TestCase): def setUp(self): self.observable = Observable() self.observer = Mock() self.observable.subscribe(self.observer) def test_notify_method_calls_update_on_observers(self): self.observable.notify() self.observer.update.assert_called_once() def test_methods_with_notify_decorator(self): # decorate `method` method = notify(lambda self: None) # pass `self.observable` as the first arguments to emulate a instance # method method(self.observable) self.observer.update.assert_called_once() def test_unsubscribe(self): self.observable.unsubscribe(self.observer) self.observable.notify() self.assertFalse(self.observer.update.called)
def setUp(self): self.observable = Observable() self.observer = Mock() self.observable.subscribe(self.observer)
def __init__(self): UnsortedActiveList.__init__(self) Observable.__init__(self) self.timelines = [] self.visible = []