def get_valid_mission_missionary(): result = [] mission_id_to_missionary = Missionary.get_valid_mission_id_to_missionary() mission_line = Mission.get_valid_missions() log.info('all valid mission: {}'.format(tuple(mission_line))) for mission in mission_line: missionary = mission_id_to_missionary.get(mission.id, None) if missionary: if mission.is_valid: result.append({'mission': mission, 'missionary': missionary}) else: log.info('mission({})\'s missionary not found, create new'.format( mission)) missionary = Missionary.create_by_mission(mission) result.append({'mission': mission, 'missionary': missionary}) log.info('get valid mission missionary: {}'.format(result)) return result
def do_run_mission(mission_id): mission = Mission.query.filter_by(id=mission_id).first() if not mission.is_valid: return False missionary = Missionary.get_or_create_by_mission(mission) mission_engine = MissionaryEngine(mission, missionary) return mission_engine.try_pass()
def test_can_not_run_before_each_task(): can_not_run_before_each_task_mission = create_can_not_run_before_each_task_mission( ) can_not_run_before_each_task_missionary = Missionary.create_by_mission( can_not_run_before_each_task_mission) mission_engine = MissionaryEngine(can_not_run_before_each_task_mission, can_not_run_before_each_task_missionary) assert mission_engine.can_run_before_each_task() is False
def create_not_end_missionary(mission_id): return Missionary(mission_id=mission_id)
def create_is_end_missionary(mission_id): return Missionary(mission_id=mission_id, is_end=True)
def create_not_end_missionary(self, mission_id): return Missionary(mission_id=mission_id).save()
def create_is_end_missionary(self, mission_id): return Missionary(mission_id=mission_id, is_end=True).save()