Ejemplo n.º 1
0
def test_update_receipt(mocker):
    mocked_internal_func = mocker.patch.object(ReceiptStorage,
                                               'update_receipt')

    receipt_controller = ReceiptController(ReceiptStorage())

    sugar = ModelControllerIngredient(id=-1, name='sugar', calories=100)
    receipt_controller.update_receipt(sugar)

    mocked_internal_func.assert_called_with(sugar)
Ejemplo n.º 2
0
def update_receipt(controller: ReceiptController):
    """
    Update a receipt
    :param controller:
    :return:
    """
    try:
        content = json.dumps(request.json)
        receipt = json2obj(content)
        controller.update_receipt(receipt)
    except Exception as e:
        print(e)
        return Response("Error", status=500, mimetype='application/json')

    return Response("Ok", status=200, mimetype='application/json')