コード例 #1
0
def test_database_retrieve_answer_manager_handles_404(mock_retrieve_answers,
                                                      sso_request, sso_user):
    mock_retrieve_answers.return_value = create_response(404)

    manager = helpers.DatabaseTriageAnswersManager(sso_request)

    assert manager.retrieve_answers() == {}
コード例 #2
0
def test_database_retrieve_answer_manager_handles_api_error(
        mock_retrieve_answers, sso_request, sso_user):
    mock_retrieve_answers.return_value = create_response(400)

    manager = helpers.DatabaseTriageAnswersManager(sso_request)

    with pytest.raises(requests.HTTPError):
        manager.retrieve_answers()
コード例 #3
0
def test_database_create_answer_manager_handles_api_error(
        mock_create_triage_result, sso_request, sso_user):
    mock_create_triage_result.return_value = create_response(400)

    data = {'field': 'value'}
    manager = helpers.DatabaseTriageAnswersManager(sso_request)

    with pytest.raises(requests.HTTPError):
        manager.persist_answers(data)
コード例 #4
0
def test_database_retrieve_manager_calls_api(mock_retrieve_answers,
                                             sso_request, sso_user):
    mock_retrieve_answers.return_value = create_response(200, {'key': 'value'})

    manager = helpers.DatabaseTriageAnswersManager(sso_request)
    answers = manager.retrieve_answers()

    assert mock_retrieve_answers.call_count == 1
    assert mock_retrieve_answers.call_args == call(
        sso_session_id=sso_user.session_id, )
    assert answers == {'key': 'value'}
コード例 #5
0
def test_database_answer_manager_update_calls_api(mock_update_triage_result,
                                                  sso_request, sso_user):
    mock_update_triage_result.return_value = create_response(200)

    data = {'field': 'value'}
    manager = helpers.DatabaseTriageAnswersManager(sso_request)
    manager.persist_answers(data)

    assert mock_update_triage_result.call_count == 1
    assert mock_update_triage_result.call_args == call(
        form_data=data,
        sso_session_id=sso_user.session_id,
    )