def test_get_qid_non_404_returned(app_test_client):
    # Given
    responses.add(responses.GET, f'{TestConfig.CASE_API_URL}/qids/{TEST_QID_JSON["questionnaireId"]}',
                  status=500)

    # When
    with app_test_client.app_context():
        with pytest.raises(HTTPError):
            get_qid(TEST_QID_JSON['questionnaireId'], TestConfig.CASE_API_URL)
Пример #2
0
def get_qid_for_linking():
    qid = request.args['qid']
    case_id = request.args['case_id']

    uac_qid_link = case_controller.get_qid(qid,
                                           current_app.config['CASE_API_URL'])
    if uac_qid_link is None:
        flash('QID does not exist in RM', category='error')
        return redirect(
            url_for('case_details_bp.case_details_results', case_id=case_id))

    case = case_controller.get_summary_case_details(
        case_id, current_app.config['CASE_API_URL'])
    if is_ccs_type_qid(qid) and not case['surveyType'] == 'CCS':
        flash('Linking a CCS QID to a non CCS case is forbidden',
              category='error')
        return redirect(
            url_for('case_details_bp.case_details_results', case_id=case_id))
    if not is_ccs_type_qid(qid) and case['surveyType'] == 'CCS':
        flash('Linking a non CCS QID to a CCS case is forbidden',
              category='error')
        return redirect(
            url_for('case_details_bp.case_details_results', case_id=case_id))

    return render_template('link_qid_to_case.html',
                           uac_qid_link=uac_qid_link,
                           case_id_to_link=case_id)
def test_get_qid(app_test_client):
    # Given
    responses.add(responses.GET, f'{TestConfig.CASE_API_URL}/qids/{TEST_QID_JSON["questionnaireId"]}',
                  json.dumps(TEST_QID_JSON))

    # When
    with app_test_client.app_context():
        qid_response = get_qid(TEST_QID_JSON['questionnaireId'], TestConfig.CASE_API_URL)

    # Then
    unittest_helper.assertEqual(qid_response, TEST_QID_JSON)
Пример #4
0
def get_qid_for_linking():
    qid = request.args['qid']
    case_id = request.args['case_id']

    uac_qid_link = case_controller.get_qid(qid,
                                           current_app.config['CASE_API_URL'])
    if uac_qid_link is None:
        flash('QID does not exist in RM', category='error')
        return redirect(
            url_for('case_details_bp.case_details_results', case_id=case_id))

    return render_template('link_qid_to_case.html',
                           uac_qid_link=uac_qid_link,
                           case_id_to_link=case_id)