예제 #1
0
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
예제 #2
0
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()
예제 #3
0
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
예제 #4
0
def create_not_end_missionary(mission_id):
    return Missionary(mission_id=mission_id)
예제 #5
0
def create_is_end_missionary(mission_id):
    return Missionary(mission_id=mission_id, is_end=True)
예제 #6
0
 def create_not_end_missionary(self, mission_id):
     return Missionary(mission_id=mission_id).save()
예제 #7
0
 def create_is_end_missionary(self, mission_id):
     return Missionary(mission_id=mission_id, is_end=True).save()