def setUp(self): super(TestPendingNotifications, self).setUp() class FakeNotifier(object): def __init__(self): self.notifications = [] def on_event(self, event): self.notifications.append(event) self.notifier = FakeNotifier() self.pending_notifications = PendingNotifications(self.notifier)
def setUp(self): super(TestPendingNotifications, self).setUp() class FakeNotifier(object): def __init__(self): self.notifications = [] def on_event(self, event): self.notifications.append(event) self.notifier = FakeNotifier() self.pending_notifications = PendingNotifications(self.notifier)
class TestPendingNotifications(unittest.TestCase): """Test PendingNotifications.""" def setUp(self): super(TestPendingNotifications, self).setUp() class FakeNotifier(object): def __init__(self): self.notifications = [] def on_event(self, event): self.notifications.append(event) self.notifier = FakeNotifier() self.pending_notifications = PendingNotifications(self.notifier) def test_send_with_no_events(self): """If no events are pending, no notifications are sent.""" self.pending_notifications.send() self.assertEqual(0, len(self.notifier.notifications)) def test_send_does_send_single_event(self): """If a single event is pending, it should still be sent.""" share = FakeShare() events = [ShareCreated(*share.event_args)] self.pending_notifications.add_events(events) self.pending_notifications.send() self.assertEqual(1, len(self.notifier.notifications)) self.assertEqual(events, self.notifier.notifications)
class TestPendingNotifications(unittest.TestCase): """Test PendingNotifications.""" def setUp(self): super(TestPendingNotifications, self).setUp() class FakeNotifier(object): def __init__(self): self.notifications = [] def on_event(self, event): self.notifications.append(event) self.notifier = FakeNotifier() self.pending_notifications = PendingNotifications(self.notifier) def test_send_with_no_events(self): """If no events are pending, no notifications are sent.""" self.pending_notifications.send() self.assertEqual(0, len(self.notifier.notifications)) def test_send_does_send_single_event(self): """If a single event is pending, it should still be sent.""" share = FakeShare() events = [ShareCreated(*share.event_args)] self.pending_notifications.add_events(events) self.pending_notifications.send() self.assertEqual(1, len(self.notifier.notifications)) self.assertEqual(events, self.notifier.notifications)