Beispiel #1
0
def test_delete_product_if_product_not_found_raises_not_found_error(
        _product_exists_and_belongs_to_user_mock,
        delete_one_by_id_mock, user_data, product_data):
    _product_exists_and_belongs_to_user_mock.side_effect = NotFoundError("not found")
    delete_one_by_id_mock.return_value = False
    with pytest.raises(NotFoundError):
        ProductsService.delete_product(user_data.uid, product_data.product_id)
def delete_product(product_id):
    """Servicio de eliminación de un artículo"""
    uid = get_jwt_identity()
    ProductsService.delete_product(uid, product_id)
    return jsonify(result='success'), 200
Beispiel #3
0
def test_delete_product(_product_exists_and_belongs_to_user_mock,
                        delete_one_by_id_mock, user_data, product_data):
    _product_exists_and_belongs_to_user_mock.return_value = True
    delete_one_by_id_mock.return_value = True
    assert ProductsService.delete_product(user_data.uid, product_data.product_id)
Beispiel #4
0
def test_delete_product_if_user_doesnt_own_product_raises_forbidden_error\
                (_product_exists_and_belongs_to_user_mock, user_data, product_data):
    _product_exists_and_belongs_to_user_mock.side_effect = ForbiddenError("forbidden")
    with pytest.raises(ForbiddenError):
        ProductsService.delete_product(user_data.uid, product_data.product_id)