Esempio n. 1
0
 def test_today_in_range(self):
     self.assertTrue(today_in_range(None, None))
     self.assertTrue(today_in_range(date.today(), None))
     self.assertTrue(today_in_range(None, date.today()))
     self.assertTrue(today_in_range(date.today(), date.today()))
     self.assertTrue(today_in_range(date.today() - timedelta(days=1),
                                    date.today() + timedelta(days=1)))
     self.assertFalse(today_in_range(date.today() - timedelta(days=1),
                                     date.today() - timedelta(days=1)))
     self.assertFalse(today_in_range(date.today() + timedelta(days=1),
                                     date.today() + timedelta(days=1)))
     self.assertFalse(today_in_range(date.today() + timedelta(days=1),
                                     None))
     self.assertFalse(today_in_range(None,
                                     date.today() - timedelta(days=1)))
Esempio n. 2
0
 def test_today_in_range(self):
     self.assertTrue(today_in_range(None, None))
     self.assertTrue(today_in_range(date.today(), None))
     self.assertTrue(today_in_range(None, date.today()))
     self.assertTrue(today_in_range(date.today(), date.today()))
     self.assertTrue(
         today_in_range(date.today() - timedelta(days=1),
                        date.today() + timedelta(days=1)))
     self.assertFalse(
         today_in_range(date.today() - timedelta(days=1),
                        date.today() - timedelta(days=1)))
     self.assertFalse(
         today_in_range(date.today() + timedelta(days=1),
                        date.today() + timedelta(days=1)))
     self.assertFalse(today_in_range(date.today() + timedelta(days=1),
                                     None))
     self.assertFalse(today_in_range(None,
                                     date.today() - timedelta(days=1)))
Esempio n. 3
0
    def active(self):
        """Returns whether or not this banner is currently active.

        A banner is active if either it has no publication date, or the
        publication date is in the past, and either it has no expiration date,
        or the expiration date is in the future.

        Banners are considered active if their publication date or expiration
        date are the current day.

        """

        return today_in_range(self.publish_from, self.publish_until)
Esempio n. 4
0
    def active(self):
        """Returns whether or not this banner is currently active.

        A banner is active if either it has no publication date, or the
        publication date is in the past, and either it has no expiration date,
        or the expiration date is in the future.

        Banners are considered active if their publication date or expiration
        date are the current day.

        """

        return today_in_range(self.publish_from, self.publish_until)