Пример #1
0
class CheckBounceWindow(unittest.TestCase):
    def setUp(self):
        self.eastern = BounceWindow(green='5-7', yellow='8-11')
        self.pacific = BounceWindow(green='2-4', yellow='5-7')

    def testStatus(self):
        """Test lookup of bounce window status."""
        # 00:00 UTC, 19:00 EST
        when = datetime(2006, 1, 3, tzinfo=UTC)
        self.assertEquals(self.eastern.status(when), 'red')
        # 03:00 PST, 14:00 UTC
        then = pacific.localize(datetime(2013, 6, 4))
        self.assertEquals(self.pacific.status(then), 'green')

    def testNextOk(self):
        """Test bounce window next_ok() method."""
        when = datetime(2013, 1, 3, 22, 15, tzinfo=UTC)
        next_ok = self.pacific.next_ok('yellow', when)
        # Did we get the right answer?  (2 am PST the next morning)
        self.assertEquals(next_ok.tzinfo, UTC)
        self.assertEquals(next_ok.astimezone(eastern).hour, 2)
        self.assertEquals(next_ok, datetime(2013, 1, 4, 7, 0, tzinfo=UTC))
        self.assertEquals(self.pacific.status(next_ok), 'green')
        # next_ok() should return current time if already ok.
        self.assertEquals(self.pacific.next_ok('yellow', next_ok), next_ok)
        then = datetime(2013, 1, 3, 22, 15, tzinfo=UTC)
        self.assertEquals(self.pacific.next_ok('red', then), then)
Пример #2
0
 def testWeekend(self):
     """Test weekend moratorium."""
     when = datetime(2006, 1, 6, 20, tzinfo=UTC)
     next_ok = BounceWindow(green='5-7', yellow='8-11').next_ok('green', when)
     self.assertEquals(next_ok, datetime(2006, 1, 9, 10, tzinfo=UTC))
Пример #3
0
 def setUp(self):
     self.eastern = BounceWindow(green='5-7', yellow='8-11')
     self.pacific = BounceWindow(green='2-4', yellow='5-7')
Пример #4
0
 def setUp(self):
     self.est = BounceWindow(green='5-7', yellow='8-11')
     self.pst = BounceWindow(green='2-4', yellow='5-7')