def test_is_similar_default(self): notification = mod.Notification('uid', 'msg', 'now', category='content', read_at='now', username='******', db=mock.Mock()) group = mod.NotificationGroup([notification]) similar = mod.Notification('uid', 'msg', 'now', category='content', read_at='now', username='******', db=mock.Mock()) different1 = mod.Notification('uid', 'msg', 'now', category='other', read_at='now', username='******', db=mock.Mock()) different2 = mod.Notification('uid', 'msg', 'now', category='content', read_at='yesterday', username='******', db=mock.Mock()) assert group.is_similar(similar, attrs=('category', 'read_at')) assert not group.is_similar(different1, attrs=('category', 'read_at')) assert not group.is_similar(different2, attrs=('category', 'read_at'))
def test_add(self): notification = mod.Notification('uid', 'msg', 'now', db=mock.Mock()) group = mod.NotificationGroup() group.add(notification) assert group.notifications == [notification]
def test_empty_group(self): group = mod.NotificationGroup() with pytest.raises(ValueError): group.category
def test_count(self): notification = mod.Notification('uid', 'msg', 'now', db=mock.Mock()) notification2 = mod.Notification('uid2', 'msg', 'now', db=mock.Mock()) group = mod.NotificationGroup([notification, notification2]) assert group.count == 2
def test_notification_attrs(self, request): notification = mod.Notification('uid', 'msg', 'now', db=mock.Mock()) group = mod.NotificationGroup([notification]) for attr in mod.NotificationGroup.proxied_attrs: assert getattr(group, attr) == getattr(notification, attr)