Commits

Jason R. Coombs  committed 44409ca

Added a test for something I would like to work - it should be possible to get the next command without deference to the current time.

  • Participants
  • Parent commits b7816c2

Comments (0)

Files changed (1)

File irc/tests/test_schedule.py

 		)
 	assert fd.due() == True
 	assert fd.next().due() == False
+
+class TestCommands(object):
+	def test_command_at_noon(self):
+		"""
+		Create a periodic command that's run at noon every day.
+		"""
+		when = datetime.time(12,0)
+		daily = datetime.timedelta(days=1)
+		# convert when to the next datetime matching this time
+		when = datetime.datetime.combine(datetime.date.today(), when)
+		if when < datetime.datetime.now():
+			when += daily
+		cmd = schedule.PeriodicCommandFixedDelay.at_time(
+			when, daily, function=None, arguments=None)
+		assert cmd.due() is False
+		next_cmd = cmd.next()
+		day_from_now = datetime.datetime.now() + daily
+		two_days_from_now = day_from_now + daily
+		assert day_from_now < next_cmd < two_days_from_now