Ejemplo n.º 1
0
    def test_timing(self):
        event = EventModel()
        event.active = True
        event.days = '1,3'
        event.hours = '13,20'
        event.minutes = '12'

        self.assertEqual(event.last_run, None)
        self.assertFalse(event.due_for_execution(datetime(2010, 9, 21, 14, 0)))
        self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))
        event.last_run = datetime.now()
        self.assertFalse(event.due_for_execution(datetime(2010, 9, 21, 13,
                                                          13)))

        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 13, 25)),
            datetime(2010, 9, 21, 13, 12))

        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 21, 0)),
            datetime(2010, 9, 21, 20, 12))

        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)),
            datetime(2010, 9, 16, 20, 12))

        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 1, 1, 12, 19)),
            datetime(2009, 12, 31, 20, 12))

        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 13, 12)),
            datetime(2010, 9, 16, 20, 12))

        event.minutes = None
        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)),
            datetime(2010, 9, 16, 20, 0))

        event.days = None
        event.hours = None
        event.minutes = None
        self.assertEqual(
            event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)), None)

        event.days = None
        event.hours = '13,20'
        event.minutes = '12'
        event.last_run = None
        self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))

        event.days = None
        event.hours = None
        event.minutes = '12'
        event.last_run = None
        self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))
        self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 1, 13)))
Ejemplo n.º 2
0
	def test_timing(self):
		event = EventModel()
		event.active = True
		event.days = '1,3'
		event.hours = '13,20'
		event.minutes = '12'
		
		self.assertEqual(event.last_run, None)
		self.assertFalse(event.due_for_execution(datetime(2010, 9, 21, 14, 0)))
		self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))
		event.last_run = datetime.now()
		self.assertFalse(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))
		
		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 13, 25)), datetime(2010, 9, 21, 13, 12))

		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 21, 0)), datetime(2010, 9, 21, 20, 12))

		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)), datetime(2010, 9, 16, 20, 12))

		self.assertEqual(event.latest_scheduled_time(datetime(2010, 1, 1, 12, 19)), datetime(2009, 12, 31, 20, 12))

		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 13, 12)), datetime(2010, 9, 16, 20, 12))

		event.minutes = None
		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)), datetime(2010, 9, 16, 20, 0))

		event.days = None
		event.hours = None
		event.minutes = None
		self.assertEqual(event.latest_scheduled_time(datetime(2010, 9, 21, 12, 19)), None)

		event.days = None
		event.hours = '13,20'
		event.minutes = '12'
		event.last_run = None
		self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))

		event.days = None
		event.hours = None
		event.minutes = '12'
		event.last_run = None
		self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 13, 13)))
		self.assertTrue(event.due_for_execution(datetime(2010, 9, 21, 1, 13)))
Ejemplo n.º 3
0
def print_times():
	# just used to eyeball the time strings
	event = EventModel()
	print 'Empty:', event.time_description()

	event.days = '1'
	print 'Tuesday at midnight:', event.time_description()

	event.days = '1,3'
	event.hours = '0, 12'
	print 'Tuesday and Thursday at midnight and noon:', event.time_description()

	event.days = '1,3'
	event.hours = '0,12'
	event.minutes = '15,45'
	print 'Tuesday and Thursday at 0 and 12 hours and 15 and 45 minutes:', event.time_description()

	event.days = '1,3'
	event.hours = '14'
	event.minutes = '30'
	print 'Tuesday and Thursday at 0 and 12 hours at 30 minutes:', event.time_description()
Ejemplo n.º 4
0
def print_times():
    # just used to eyeball the time strings
    event = EventModel()
    print 'Empty:', event.time_description()

    event.days = '1'
    print 'Tuesday at midnight:', event.time_description()

    event.days = '1,3'
    event.hours = '0, 12'
    print 'Tuesday and Thursday at midnight and noon:', event.time_description(
    )

    event.days = '1,3'
    event.hours = '0,12'
    event.minutes = '15,45'
    print 'Tuesday and Thursday at 0 and 12 hours and 15 and 45 minutes:', event.time_description(
    )

    event.days = '1,3'
    event.hours = '14'
    event.minutes = '30'
    print 'Tuesday and Thursday at 0 and 12 hours at 30 minutes:', event.time_description(
    )