def zeroing(): begin = utils.now().replace(hour=0, minute=0, second=0, microsecond=0) tasks = Task.query.filter(Task.start_time > utils.get_current_monday(), Task.start_time < utils.now()) burnings = {} for task in tasks: if task.status == 'PROGRESS': task.status = 'READY' end_time = utils.now() if end_time.hour > 18: end_time = end_time.replace(hour=18, minute=0, second=0) task.time_slots.append( TimeSlot(task.start_time, (end_time - task.start_time).total_seconds(), task.owner, partner=task.partner)) task.owner = None task.partner = None burning = burnings.setdefault(task.team.id, Burning(task.team, begin)) burning.add(task) for key, item in burnings.iteritems(): db.session.add(item) db.session.commit()
def setUp(self): BaseTestCase.setUp(self) when(miami.utils).now().thenReturn(datetime(2012, 11, 5, 9, 0, 0)) team = Team('Miami') team.members.append(User.query.get(1)) self.create_entity(team) burning = Burning(Team.query.get(1), miami.utils.get_current_monday()) burning.burning = 1 burning.remaining = 10 self.create_entity(burning) burning = Burning(Team.query.get(1), miami.utils.get_current_monday() + timedelta(days=1)) burning.burning = 2 burning.remaining = 8 self.create_entity(burning) task = Task('title1', 'detail', status='DONE', price=1, estimate=4, team=Team.query.get(1)) self.create_entity(task) task = Task('title1', 'detail', status='PROGRESS', price=1, estimate=4, team=Team.query.get(1)) self.create_entity(task) task = Task('title1', 'detail', status='READY', price=1, estimate=4, team=Team.query.get(1)) self.create_entity(task) task = Task('title1', 'detail', status='NEW', price=1, estimate=4, team=Team.query.get(1)) self.create_entity(task)
db.session.add(task) db.session.commit() task = Task('title7', 'detail5', status='DONE', price=2, estimate=4, team=Team.query.get(1), start_time=miami.utils.yestoday().replace(hour=14), ready_time=miami.utils.yestoday().replace(hour=14)) ts = TimeSlot(task.start_time, 3600, User.query.get(2)) task.categories.append(Category.query.get(2)) task.time_slots.append(ts) db.session.add(task) db.session.commit() task = Task('title8', 'detail4', status='NEW', team=Team.query.get(1)) task.categories.append(Category.query.get(2)) db.session.add(task) db.session.commit() task = Task('title9', 'detail4', status='NEW', team=Team.query.get(1)) task.categories.append(Category.query.get(2)) db.session.add(task) db.session.commit() burning = Burning(Team.query.get(1), miami.utils.get_current_monday()) burning.burning = 1 burning.remaining = 10 db.session.add(burning) db.session.commit() burning = Burning(Team.query.get(1), miami.utils.get_current_monday() + timedelta(days=1)) burning.burning = 2 burning.remaining = 8 db.session.add(burning) db.session.commit()
team=Team.query.get(1), start_time=miami.utils.yestoday().replace(hour=14), ready_time=miami.utils.yestoday().replace(hour=14)) ts = TimeSlot(task.start_time, 3600, User.query.get(2)) task.categories.append(Category.query.get(2)) task.time_slots.append(ts) db.session.add(task) db.session.commit() task = Task('title8', 'detail4', status='NEW', team=Team.query.get(1)) task.categories.append(Category.query.get(2)) db.session.add(task) db.session.commit() task = Task('title9', 'detail4', status='NEW', team=Team.query.get(1)) task.categories.append(Category.query.get(2)) db.session.add(task) db.session.commit() burning = Burning(Team.query.get(1), miami.utils.get_current_monday()) burning.burning = 1 burning.remaining = 10 db.session.add(burning) db.session.commit() burning = Burning(Team.query.get(1), miami.utils.get_current_monday() + timedelta(days=1)) burning.burning = 2 burning.remaining = 8 db.session.add(burning) db.session.commit()