Example #1
0
    def test_notify_observers(self):
        GlobalFigureManager.observers = []
        num = 10
        mock_observers = []
        for i in range(num):
            good_observer = Mock()
            good_observer.notify = Mock()
            GlobalFigureManager.add_observer(good_observer)
            mock_observers.append(good_observer)

        mock_figure_number = 312312
        mock_args = [FigureAction.Update, mock_figure_number]
        GlobalFigureManager.notify_observers(*mock_args)

        for obs in mock_observers:
            obs.notify.assert_called_once_with(*mock_args)
Example #2
0
 def test_add_observer(self):
     good_observer = Mock()
     good_observer.notify = Mock()
     self.assertTrue(1, len(GlobalFigureManager.observers))