def test_hold_positions_empty_update(mocker):
    model = DegiroModel()

    # MOCK API FUNCTION
    mock_update = trading_pb2.Update()
    mock_func = mocker.Mock(return_value=mock_update)
    mocker.patch.object(
        target=model.__dict__["_DegiroModel__trading_api"],
        attribute="get_update",
        new=mock_func,
    )

    result = model.hold_positions()

    assert isinstance(result, pd.DataFrame)
def test_pending(mocker):
    model = DegiroModel()

    # MOCK API FUNCTION
    mock_func = mocker.Mock(return_value=trading_pb2.Update())
    mocker.patch.object(
        target=model.__dict__["_DegiroModel__trading_api"],
        attribute="get_update",
        new=mock_func,
    )

    result = model.pending()

    mock_func.assert_called_once()
    assert isinstance(result, trading_pb2.Update.Orders)
def test_update_pending_order_none(mocker):
    model = DegiroModel()

    # MOCK API FUNCTION
    mock_update = trading_pb2.Update()
    mock_func = mocker.Mock(return_value=mock_update)
    mocker.patch.object(
        target=model.__dict__["_DegiroModel__trading_api"],
        attribute="get_update",
        new=mock_func,
    )

    result = model.update_pending_order(order_id="MOCK_ORDER_ID")

    mock_func.assert_called_once()
    assert result is None
def test_update_pending_order(mocker):
    model = DegiroModel()

    # MOCK API FUNCTION
    mock_update = trading_pb2.Update()
    mock_update.orders.values.extend([
        trading_pb2.Order(
            id="MOCK_ORDER_ID",
            product_id=1,
            size=2,
            price=3,
        ),
    ])
    mock_func = mocker.Mock(return_value=mock_update)
    mocker.patch.object(
        target=model.__dict__["_DegiroModel__trading_api"],
        attribute="get_update",
        new=mock_func,
    )

    result = model.update_pending_order(order_id="MOCK_ORDER_ID")

    mock_func.assert_called_once()
    assert isinstance(result, trading_pb2.Order)