def add_product(): """Servicio de publicación de articulo para la venta""" uid = get_jwt_identity() if not request.is_json: abort(400) product = request.get_json() product_id = ProductsService.add_product(product, uid) return jsonify(result='success', _id=product_id), 200
def test_add_product_if_wrong_schema_raises_validation_error(product_data, user_data): with pytest.raises(ValidationError): ProductsService.add_product(product_data.invalid_product, user_data.uid)
def test_add_product_if_no_product_sent_raises_validation_error(user_data): product_json = {} with pytest.raises(ValidationError): ProductsService.add_product(product_json, user_data.uid)