def test_parse_time_and_get_time_must_round_seconds_down(self):
     secs_before = int(time.time()) % 60
     get_time_result = get_time()[-2:]
     parse_time_result = parse_time('NOW') % 60
     secs_after = int(time.time()) % 60
     if secs_after == secs_before:  # Check that second has not passed during the measurements
         assert_equal(get_time_result, '%02d' % secs_before)
         assert_equal(parse_time_result % 60, secs_after)
 def test_parse_time_and_get_time_must_round_seconds_down(self):
     secs_before = int(time.time()) % 60
     get_time_result = get_time()[-2:]
     parse_time_result = parse_time('NOW') % 60
     secs_after = int(time.time()) % 60
     if secs_after == secs_before: # Check that second has not passed during the measurements
         assert_equal(get_time_result, '%02d' % secs_before)
         assert_equal(parse_time_result % 60, secs_after)
 def _verify_parse_time_and_get_time_rounding(self):
     secs = lambda: int(time.time()) % 60
     start_secs = secs()
     gt_result = get_time()[-2:]
     pt_result = parse_time('NOW') % 60
     # Check that seconds have not changed during test
     if secs() == start_secs:
         assert_equal(gt_result, '%02d' % start_secs)
         assert_equal(pt_result, start_secs)
Beispiel #4
0
 def _verify_parse_time_and_get_time_rounding(self):
     secs = lambda: int(time.time()) % 60
     start_secs = secs()
     gt_result = get_time()[-2:]
     pt_result = parse_time('NOW') % 60
     # Check that seconds have not changed during test
     if secs() == start_secs:
         assert_equal(gt_result, '%02d' % start_secs)
         assert_equal(pt_result, start_secs)
 def test_parse_modified_time_with_now(self):
     for input, adjusted in [
         ('now', 0), ('NOW', 0), ('Now', 0), ('now + 100 seconds', 100),
         ('now - 100 seconds', -100), ('now + 1 day 100 seconds', 86500),
         ('now - 1 day 100 seconds', -86500),
         ('now + 1 day 10 hours 1 minute 10 seconds', 122470),
         ('now - 1 day 10 hours 1 minute 10 seconds', -122470),
         ('now +   100 seconds', 100)
     ]:
         exp = get_time('epoch') + adjusted
         parsed = parse_time(input)
         assert_true(exp <= parsed <= exp + 1,
                     "%d <= %d <= %d" % (exp, parsed, exp + 1))
Beispiel #6
0
 def test_parse_time_with_now_and_utc(self):
     for input, adjusted in [('now', 0), ('NOW', 0), ('Now', 0),
                             ('now+100seconds', 100),
                             ('now    -    100    seconds   ', -100),
                             ('now + 1 day 100 seconds', 86500),
                             ('now - 1 day 100 seconds', -86500),
                             ('now + 1day 10hours 1minute 10secs', 122470),
                             ('NOW - 1D 10H 1MIN 10S', -122470)]:
         expected = get_time('epoch') + adjusted
         parsed = parse_time(input)
         assert_true(expected <= parsed <= expected + 1),
         parsed = parse_time(input.upper().replace('NOW', 'UtC'))
         zone = time.altzone if time.localtime().tm_isdst else time.timezone
         expected += zone
         assert_true(expected <= parsed <= expected + 1),
 def test_parse_time_with_now_and_utc(self):
     for input, adjusted in [('now', 0),
                             ('NOW', 0),
                             ('Now', 0),
                             ('now+100seconds', 100),
                             ('now    -    100    seconds   ', -100),
                             ('now + 1 day 100 seconds', 86500),
                             ('now - 1 day 100 seconds', -86500),
                             ('now + 1day 10hours 1minute 10secs', 122470),
                             ('NOW - 1D 10H 1MIN 10S', -122470)]:
         expected = get_time('epoch') + adjusted
         parsed = parse_time(input)
         assert_true(expected <= parsed <= expected + 1),
         parsed = parse_time(input.upper().replace('NOW', 'UtC'))
         zone = time.altzone if time.localtime().tm_isdst else time.timezone
         expected += zone
         assert_true(expected <= parsed <= expected + 1),
 def test_parse_modified_time_with_now(self):
     for input, adjusted in [('now', 0),
                             ('NOW', 0),
                             ('Now', 0),
                             ('now + 100 seconds', 100),
                             ('now - 100 seconds', -100),
                             ('now + 1 day 100 seconds', 86500),
                             ('now - 1 day 100 seconds', -86500),
                             ('now + 1 day 10 hours 1 minute 10 seconds',
                              122470),
                             ('now - 1 day 10 hours 1 minute 10 seconds',
                              -122470),
                             ('now +   100 seconds', 100)]:
         exp = get_time('epoch') + adjusted
         parsed = parse_time(input)
         assert_true(exp <= parsed <= exp +1,
                     "%d <= %d <= %d" % (exp, parsed, exp+1) )