def test_with_one_non_comment_notification(self): # Given a single non-comment notification, a single tuple is # generated. notification = FakeNotification(False) self.assertEquals( [(1, notification)], list(notification_comment_batches([notification])))
def test_with_two_notifications_comment_last(self): # Given two notifications, one a comment, one not, and the comment # last, two tuples are generated, both in the same group. notification1 = FakeNotification(False) notification2 = FakeNotification(True) notifications = [notification1, notification2] self.assertEquals( [(1, notification1), (1, notification2)], list(notification_comment_batches(notifications)))
def test_with_three_notifications_comment_in_middle(self): # Given three notifications, one a comment, two not, and the comment # in the middle, three tuples are generated, all in the same group. notification1 = FakeNotification(False) notification2 = FakeNotification(True) notification3 = FakeNotification(False) notifications = [notification1, notification2, notification3] self.assertEquals( [(1, notification1), (1, notification2), (1, notification3)], list(notification_comment_batches(notifications)))
def test_with_more_notifications(self): # Given four notifications - non-comment, comment, non-comment, # comment - four tuples are generated. The first three notifications # are in the first group, the last notification is in a group on its # own. notification1 = FakeNotification(False) notification2 = FakeNotification(True) notification3 = FakeNotification(False) notification4 = FakeNotification(True) notifications = [ notification1, notification2, notification3, notification4, ] self.assertEquals( [(1, notification1), (1, notification2), (1, notification3), (2, notification4)], list(notification_comment_batches(notifications)))
def test_with_nothing(self): # Nothing is generated if an empty list is passed in. self.assertEquals([], list(notification_comment_batches([])))