def test_orders_timeslots(self):
def weekly_2_mins(weekly):
return ((weekly.weekday - 1) * 24 * 60 + weekly.start.hour * 60 +
weekly.start.minute, (weekly.weekday - 1) * 24 * 60 +
weekly.end.hour * 60 + weekly.end.minute)
orders = Order.objects.filter(status='p')
for order in orders:
timeslots = order.timeslot_set.filter(deleted=False)
weekly_time_slots = order.weekly_time_slots.all()
mins = [weekly_2_mins(x) for x in weekly_time_slots]
for timeslot in timeslots:
timeslot.start = timezone.localtime(timeslot.start)
timeslot.end = timezone.localtime(timeslot.end)
cur_min = (
timeslot.start.weekday() * 24 * 60 +
timeslot.start.hour * 60 + timeslot.start.minute,
timeslot.end.weekday() * 24 * 60 +
timeslot.end.hour * 60 + timeslot.end.minute)
self.assertIn(cur_min, mins)
评论列表
文章目录