コード例 #1
0
def add_product_question(product_id):
    """Servicio de alta de pregunta: permite realizar una pregunta
     acerca de un artículo que se encuentra publicado para la venta"""
    uid = get_jwt_identity()
    if not request.is_json:
        abort(400)
    question = request.get_json()
    product = ProductsService.add_question(question, product_id, uid)
    return jsonify(product), 200
コード例 #2
0
def test_add_question_if_not_valid_question_raises_validation_error(product_data, user_data):
    with pytest.raises(ValidationError):
        ProductsService.add_question(product_data.invalid_question, product_data.product_id, user_data.uid)
コード例 #3
0
def test_add_question_if_product_not_found_raises_not_found_error(find_one_and_update_mock, product_data, user_data):
    find_one_and_update_mock.return_value = None
    with pytest.raises(NotFoundError):
        ProductsService.add_question(product_data.valid_question, product_data.product_id, user_data.uid)