Beispiel #1
0
 def test_time_timtravel(self, seconds=1, minutes=1, microseconds=100):
     d = Delorean()
     sample = datetime(2011, 10, 10, 1, 33, 4, 121940)
     d.utcdatetime = sample
     current_time = d.datetime()
     current_time = current_time + timedelta(seconds=1, minutes=1, microseconds=100)
     d.timetravel(seconds=1, minutes=1, microseconds=100)
     self.assertEqual(d.time(), current_time.time())
        # Check each day until we hit the day that is today, in the
        # user's timezone.
        for range in schedule.ranges:
            if range.day is not None and range.day.name == day_names[day]:

                # Print out today's users who have hours, as an aid.
                print "%s\t%s\t%s" % (luser.profile[0].username,
                                      range.start_time,
                                      range.end_time)

                
                # Only notify within the first 15 minutes of the hour after.
                # This will allow us to use the flow of time to avoid 
                # duplicating notifications.
                time_now = now.time()
               

                end_time_in_minutes = range.end_time.hour * 60 + range.end_time.minute
                now_in_minutes = time_now.hour * 60 + time_now.minute

                # If it is within 15 minutes after an hour has passed,
                # send the reminder email
                if end_time_in_minutes + 60 < now_in_minutes and \
                    now_in_minutes < end_time_in_minutes + 75:

                    # send the email.
                    mailer.send(from_addr=MAIL_FROM, to_addr=luser.email,
                                subject="Reminder: Please report in on %s" % \
                                schedule.project.name,
                                text=message % \