コード例 #1
0
def remove_tag(scenario_id):
    scenario = get_scenario(scenario_id)
    case_id = check_none_and_blank(request, 'case_id')
    case = get_tstcase(case_id)
    tag_id = check_none_and_blank(request, 'tag_id')
    tag = get_tagcase(tag_id)
    db.session.delete(tag)
    db.session.commit()
    return make_response(jsonify(message='TAG_REMOVED'))
コード例 #2
0
def register_tag(scenario_id):
    """POST endpoint for adding a tag to a case.

    Param:
        {
        'case_id': required,
        'tag': required
        }
    """
    scenario = get_scenario(scenario_id)
    case_id = check_none_and_blank(request, 'case_id')
    case = get_tstcase(case_id)
    tag = check_none_and_blank(request, 'tag')
    new_tag = TagCase(case_id=case_id, tag=tag)
    db.session.add(new_tag)
    db.session.commit()

    return make_response(jsonify(message='TAG_CREATED'))
コード例 #3
0
ファイル: testcases.py プロジェクト: leoGalani/sherlock
def remove_tag(scenario_id):
    scenario = get_scenario(scenario_id)
    case_id = check_none_and_blank(request, 'case_id')
    case = get_tstcase(case_id)
    tag_id = check_none_and_blank(request, 'tag_id')
    tag = get_tagcase(tag_id)
    db.session.delete(tag)
    db.session.commit()
    return make_response(jsonify(message='TAG_REMOVED'))
コード例 #4
0
def tstcase_changestatus(scenario_id):
    """POST endpoint for new scenarios.

    Param:
        {
         'case_id': required,
         'action': required,
        }

    TODO: State is not defined
    """

    case_id = check_none_and_blank(request, 'case_id')
    action = check_none_and_blank(request, 'action')
    scenario = get_scenario(scenario_id)
    tst_case = get_tstcase(case_id)

    if scenario.state_code == StateType.disable:
        return make_response(jsonify(message='SCENARIO_DISABLED'))

    last_cycle = get_last_cycle(scenario.project_id)

    if last_cycle:
        cycle_case = CycleCases.query.filter_by(
            cycle_id=last_cycle.id).filter_by(case_id=case_id).first()

    if action == 'DISABLE':
        state = StateType.disable
        cycle_state = StateType.blocked
    elif action == 'ENABLE':
        state = StateType.active
        cycle_state = StateType.not_executed
    elif action == 'REMOVE':
        if last_cycle and last_cycle.state_code == StateType.active:
            cycle_state = None
            if cycle_case:
                db.session.delete(cycle_case)
                db.session.commit()
        state = StateType.removed
    else:
        return make_response(jsonify(message='ACTION_UNKNOW'))

    tst_case.state_code = state
    db.session.add(tst_case)
    db.session.commit()

    if last_cycle:
        if last_cycle.state_code == StateType.active:
            if cycle_case and cycle_state:
                cycle_case.state_code = cycle_state
                db.session.add(cycle_case)
                db.session.commit()

    return make_response(jsonify(message='DONE'))
コード例 #5
0
ファイル: testcases.py プロジェクト: leoGalani/sherlock
def tstcase_changestatus(scenario_id):
    """POST endpoint for new scenarios.

    Param:
        {
         'case_id': required,
         'action': required,
        }

    TODO: State is not defined
    """

    case_id = check_none_and_blank(request, 'case_id')
    action = check_none_and_blank(request, 'action')
    scenario = get_scenario(scenario_id)
    tst_case = get_tstcase(case_id)

    if scenario.state_code == StateType.disable:
        return make_response(jsonify(message='SCENARIO_DISABLED'))

    last_cycle = get_last_cycle(scenario.project_id)

    if last_cycle:
        cycle_case = CycleCases.query.filter_by(
            cycle_id=last_cycle.id).filter_by(case_id=case_id).first()

    if action == 'DISABLE':
        state = StateType.disable
        cycle_state = StateType.blocked
    elif action == 'ENABLE':
        state = StateType.active
        cycle_state = StateType.not_executed
    elif action == 'REMOVE':
        if last_cycle and last_cycle.state_code == StateType.active:
            cycle_state = None
            if cycle_case:
                db.session.delete(cycle_case)
                db.session.commit()
        state = StateType.removed
    else:
        return make_response(jsonify(message='ACTION_UNKNOW'))

    tst_case.state_code = state
    db.session.add(tst_case)
    db.session.commit()

    if last_cycle:
        if last_cycle.state_code == StateType.active:
            if cycle_case and cycle_state:
                cycle_case.state_code = cycle_state
                db.session.add(cycle_case)
                db.session.commit()

    return make_response(jsonify(message='DONE'))
コード例 #6
0
def edit(scenario_id):
    """POST endpoint for edit scenarios.

    Param:
        {
         'case_name': required,
         'case_id': required
        }
    """
    case_id = check_none_and_blank(request, 'case_id')
    new_case_name = check_none_and_blank(request, 'case_name')

    edited_tc = get_tstcase(case_id)

    edited_tc.name = new_case_name
    db.session.add(edited_tc)
    db.session.commit()

    return make_response(jsonify(message='CASE_EDITED'))
コード例 #7
0
ファイル: testcases.py プロジェクト: leoGalani/sherlock
def register_tag(scenario_id):
    """POST endpoint for adding a tag to a case.

    Param:
        {
        'case_id': required,
        'tag': required
        }
    """
    scenario = get_scenario(scenario_id)
    case_id = check_none_and_blank(request, 'case_id')
    case = get_tstcase(case_id)
    tag = check_none_and_blank(request, 'tag')
    new_tag = TagCase(case_id=case_id,
                      tag=tag)
    db.session.add(new_tag)
    db.session.commit()

    return make_response(jsonify(message='TAG_CREATED'))
コード例 #8
0
ファイル: testcases.py プロジェクト: leoGalani/sherlock
def edit(scenario_id):
    """POST endpoint for edit scenarios.

    Param:
        {
         'case_name': required,
         'case_id': required
        }
    """
    case_id = check_none_and_blank(request, 'case_id')
    new_case_name = check_none_and_blank(request, 'case_name')

    edited_tc = get_tstcase(case_id)

    edited_tc.name = new_case_name
    db.session.add(edited_tc)
    db.session.commit()

    return make_response(jsonify(message='CASE_EDITED'))
コード例 #9
0
def show_testcase(scenario_id, test_case_id):
    """Return Testcase Info."""
    tst_case = get_tstcase(test_case_id)
    tstcase_schema = TestCaseSchema(many=False)
    tstcase = tstcase_schema.dump(tst_case).data
    return make_response(jsonify(tstcase))
コード例 #10
0
ファイル: testcases.py プロジェクト: leoGalani/sherlock
def show_testcase(scenario_id, test_case_id):
    """Return Testcase Info."""
    tst_case = get_tstcase(test_case_id)
    tstcase_schema = TestCaseSchema(many=False)
    tstcase = tstcase_schema.dump(tst_case).data
    return make_response(jsonify(tstcase))