Example #1
0
def test_date_handler_returns_error_when_start_date_parameter_is_not_provided(
        client):
    request = client.get(
        "/api/reports/call-history/matpal?end-date=2021-01-01").request
    with pytest.raises(BertException) as err:
        date_handler(request)
    assert err.value.message == "Invalid request, missing required date parameters"
    assert err.value.code == 400
Example #2
0
def test_date_handler_returns_error_when_end_date_value_is_not_a_valid_date(
        client):
    request = client.get(
        "/api/reports/call-history/matpal?start-date=2021-01-01&end-date=blah"
    ).request
    with pytest.raises(BertException) as err:
        date_handler(request)
    assert err.value.message == "Invalid request, date is not valid"
    assert err.value.code == 400
def call_pattern(interviewer):
    start_date, end_date = date_handler(request)
    survey_tla = survey_tla_handler(request)
    questionnaires = questionnaire_handler(request)
    results = get_call_pattern_report(interviewer, start_date, end_date, survey_tla, questionnaires)
    if results == {}:
        return {}
    else:
        return results.json()
def call_questionnaires(interviewer):
    start_date, end_date = date_handler(request)
    survey_tla = survey_tla_handler(request)
    return jsonify(get_questionnaires(interviewer, start_date, end_date, survey_tla))
def call_history(interviewer):
    start_date, end_date = date_handler(request)
    survey_tla = survey_tla_handler(request)
    questionnaires = questionnaire_handler(request)
    return jsonify(get_call_history_report(interviewer, start_date, end_date, survey_tla, questionnaires))