def close(project_id, cycle_id): # TODO: Check untested cases. """POST endpoint for closing cycles. Param: { reason: required, } """ project = get_project(project_id) cycle = get_cycle(cycle_id, project_id) if cycle.state_code == StateType.closed: return make_response(jsonify(message='CYCLE_CLOSED')) else: reason = check_none_and_blank(request, 'reason') user = g.user cycle.closed_reason = reason cycle.closed_by = user.id cycle.state_code = StateType.closed cycle.closed_at = datetime.now() cycle.last_change = datetime.now() db.session.add(cycle) db.session.commit() return make_response(jsonify(message='CYCLE_CLOSED'))
def get_cycle_resume(project_id, cycle_id): project = get_project(project_id) cycle = get_cycle(cycle_id, project_id) cycle_cases_h = CycleCases.query.filter_by(cycle_id=cycle.id).all() body_response = count_cycle_stats(cycle_cases_h) return make_response(jsonify(body_response))
def get_cases_for_cyle(project_id, cycle_id, scenario_id): project = get_project(project_id) scenario = get_scenario(scenario_id) cycle = get_cycle(cycle_id, project_id) cycle_cases_h = CycleCases.query.filter_by(cycle_id=cycle.id).all() cases = Case.query.filter_by(scenario_id=scenario.id) obj = [] for item in cycle_cases_h: for case in cases: if item.case_id == case.id: cases_tags_raw = TagCase.query.filter_by(case_id=case.id).all() schema = TagCaseSchema(many=True) case_tags = schema.dump(cases_tags_raw).data temp = {} temp['case_name'] = case.name temp['case_id'] = case.id temp['case_cycle_id'] = item.id temp['case_cycle_state'] = item.state_code.value temp['tags'] = case_tags obj.append(temp) break return make_response( jsonify(scenario_name=scenario.name, scenario_id=scenario.id, cycle_id=cycle.id, cases=obj))
def change_cycle_case_state_code_(project_id): """ Endpoint for changing the cycle cases state_code . Param: { 'cycle_id': required, 'case_id': required, 'action': required } """ action = check_none_and_blank(request, 'action') case_id = check_none_and_blank(request, 'case_id') cycle_id = check_none_and_blank(request, 'cycle_id') cycle = get_cycle(cycle_id, project_id) last_cycle = get_last_cycle(project_id) if cycle.id != last_cycle.id: return make_response(jsonify(message='NOT_LAST_CYCLE')) if action not in StateType.__members__: return make_response(jsonify(message='ACTION_UNKNOW')) edited_cycle_case = CycleCases.query.filter_by( cycle_id=cycle.id).filter_by(case_id=case_id).first() if edited_cycle_case is None: abort(make_response(jsonify(message='UNKNOW_CASE'), 404)) edited_cycle_case.state_code = StateType[action] db.session.add(edited_cycle_case) db.session.commit() return make_response(jsonify(message='CYCLE_EDITED'))
def get_scenarios_for_cyle(project_id, cycle_id): project = get_project(project_id) cycle = get_cycle(cycle_id, project_id) cycle_scenarios_h = CycleScenarios.query.filter_by(cycle_id=cycle.id).all() scenarios = Scenario.query.filter_by(project_id=project_id).all() obj = [] for item in cycle_scenarios_h: for scenario in scenarios: if scenario.id == item.scenario_id: cases = CycleCases.query.filter_by( cycle_id=cycle.id).filter_by( scenario_id=scenario.id).all() scenario_tags_raw = TagScenario.query.filter_by( scenario_id=scenario.id).all() schema = TagScenarioSchema(many=True) scenario_tags = schema.dump(scenario_tags_raw).data temp = {} temp['scenario_name'] = scenario.name temp['scenario_id'] = scenario.id temp['scenario_cycle_id'] = item.id temp['cases_stats'] = count_cycle_stats(cases) temp['tags'] = scenario_tags obj.append(temp) break return make_response(jsonify(obj))