示例#1
0
def test_select_payed_amount_empty(service: SelectReservation,
                                   context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(select_invoices_for_order=Mock(return_value=[]))

    result = service.select_payed_amount(context)
    assert is_successful(result)
    assert result.unwrap().payed_amount == Decimal(0)
示例#2
0
def test_select_payed_amount_error(service: SelectReservation,
                                   context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(select_invoices_for_order=Mock(
        side_effect=RuntimeError('ERR')))

    result = service.select_payed_amount(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
示例#3
0
def test_select_payed_amount_ok(service: SelectReservation, context: Context,
                                house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(select_invoices_for_order=Mock(return_value=[
        Mock(id=987, amount_total=50.0, amount_residual=30.0),
        Mock(id=988, amount_total=50.0, amount_residual=10.0),
    ]))

    result = service.select_payed_amount(context)
    assert is_successful(result)
    assert result.unwrap().payed_amount == Decimal(60)

    context.api.select_invoices_for_order.assert_called_once_with(321)