def test_notifications_on_home(self): """Test that notifications are displayed on the homepage.""" n1 = notification(text=u'1, 2, 3 - test', save=True) n2 = notification(text=u'Just a test.', save=True) resp = self.client.get(reverse('home')) assert n1.text in resp.content assert n2.text in resp.content
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)