def base(request): """Adds basic things to the context""" notifications = Notification.get_live_notifications() return { 'notifications': notifications, }
def base(request): """Adds basic things to the context""" notifications = Notification.get_live_notifications() return { 'request': request, 'settings': settings, 'notifications': notifications }
def test_not_shown(self): """ Test that notifications where now is before their start date or after their end date are not returned. """ start = datetime.now() + timedelta(days=2) end = datetime.now() + timedelta(days=3) n = notification(start_date=start, end_date=end, save=True) start = datetime.now() - timedelta(days=2) end = datetime.now() - timedelta(days=1) n = notification(start_date=start, end_date=end, save=True) eq_(len(Notification.get_live_notifications()), 0)
def test_shown(self): """ Test that notifications where now is between their start and end date are returned. """ start = datetime.now() - timedelta(days=2) end = datetime.now() + timedelta(days=2) n1 = notification(start_date=start, end_date=end, save=True) start -= timedelta(days=1) n2 = notification(start_date=start, end_date=end, save=True) eq_(set([x.pk for x in Notification.get_live_notifications()]), set([n1.pk, n2.pk]))
def test_not_shown(self): """ Test that notifications where now is before their start date or after their end date are not returned. """ start = datetime.now() + timedelta(days=2) end = datetime.now() + timedelta(days=3) notification(start_date=start, end_date=end, save=True) start = datetime.now() - timedelta(days=2) end = datetime.now() - timedelta(days=1) notification(start_date=start, end_date=end, save=True) eq_(len(Notification.get_live_notifications()), 0)