Exemplo n.º 1
0
def test_cancel_opportunity_error(service: CancelReservationInOdoo,
                                  context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(cancel_opportunity=Mock(
        side_effect=RuntimeError('ERR')))

    result = service.cancel_opportunity(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
Exemplo n.º 2
0
def test_cancel_opportunity_ok(service: CancelReservationInOdoo,
                               context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(cancel_opportunity=Mock(return_value=None))

    result = service.cancel_opportunity(context)
    assert is_successful(result)

    context.api.cancel_opportunity.assert_called_once_with(
        reservation.opportunity_id, CrmLostReasons.EXPENSIVE)
Exemplo n.º 3
0
def test_cancel_opportunity_for_missed_opportunity_id(
        service: CancelReservationInOdoo, context: Context, house,
        reservation):
    context.house = house
    context.reservation = attr.evolve(reservation, opportunity_id=None)
    context.api = Mock(cancel_opportunity=Mock(
        side_effect=RuntimeError('ERR')))

    result = service.cancel_opportunity(context)
    assert is_successful(result)

    context.api.cancel_opportunity.assert_not_called()