예제 #1
0
    def test_notify_observers(self):
        notifier = Notifier()

        observer1 = Mock(spec=Observer)
        observer2 = Mock(spec=Observer)

        notifier.register_observer(observer1)
        notifier.register_observer(observer2)

        notifier.notify_observers()

        observer1.notify.assert_called_once_with(notifier=notifier)
        observer2.notify.assert_called_once_with(notifier=notifier)
예제 #2
0
 def test_register_non_observer(self):
     notifier = Notifier()
     non_observer = Mock()
     notifier.register_observer(non_observer)