Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 def setUp(self):
     self.observable = Observable()
     self.observer = Mock()
     self.observable.subscribe(self.observer)
Exemplo n.º 3
0
 def __init__(self):
     UnsortedActiveList.__init__(self)
     Observable.__init__(self)
     self.timelines = []
     self.visible = []
Exemplo n.º 4
0
 def __init__(self):
     UnsortedActiveList.__init__(self)
     Observable.__init__(self)
     self.timelines = []
     self.visible = []