def add_product_answer(product_id, question_id):
    """Servicio de alta de respuesta a pregunta:
    permite responder una pregunta que fue realizada."""
    uid = get_jwt_identity()
    if not request.is_json:
        abort(400)
    answer = request.get_json()
    product = ProductsService.add_answer(answer, product_id, question_id, uid)
    return jsonify(product), 200
Beispiel #2
0
def test_add_answer_if_not_valid_answer_raises_validation_error(product_data, user_data):
    with pytest.raises(ValidationError):
        ProductsService.add_answer(product_data.invalid_answer, product_data.product_id,
                                   product_data.question_id, user_data.uid)
Beispiel #3
0
def test_add_answer_if_product_not_found_raises_not_found_error(get_by_id_mock, product_data, user_data):
    get_by_id_mock.return_value = None
    with pytest.raises(NotFoundError):
        ProductsService.add_answer(product_data.valid_answer, product_data.product_id,
                                   product_data.question_id, user_data.uid)