示例#1
0
def test_check_reservation_wrong_house(service: CancelReservationInOdoo,
                                       context: Context, house, reservation):
    context.house = house
    context.reservation = attr.evolve(reservation, house_id=999)

    result = service.check_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_reservation
示例#2
0
def test_check_reservation_not_cancelled(service: CancelReservationInOdoo,
                                         context: Context, house, reservation):
    context.house = house
    context.reservation = attr.evolve(reservation,
                                      status=ReservationStatuses.MODIFY)

    result = service.check_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_reservation
示例#3
0
def test_check_reservation_room_close(service: CancelReservationInOdoo,
                                      context: Context, house, reservation):
    context.house = house
    context.reservation = attr.evolve(reservation,
                                      status=ReservationStatuses.CLOSE)

    result = service.check_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.room_close_reservation
示例#4
0
def test_cancel_quotation_error(service: CancelReservationInOdoo,
                                context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(cancel_quotation=Mock(side_effect=RuntimeError('ERR')))

    result = service.cancel_quotation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
示例#5
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)
示例#6
0
def test_cancel_quotation_ok(service: CancelReservationInOdoo,
                             context: Context, house, reservation):
    context.house = house
    context.reservation = reservation
    context.api = Mock(cancel_quotation=Mock(return_value=None))

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

    context.api.cancel_quotation.assert_called_once_with(
        reservation.quotation_id)
示例#7
0
def test_cancel_quotation_for_missed_quotation_id(
        service: CancelReservationInOdoo, context: Context, house,
        reservation):
    context.house = house
    context.reservation = attr.evolve(reservation, quotation_id=None)
    context.api = Mock(cancel_quotation=Mock(side_effect=RuntimeError('ERR')))

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

    context.api.cancel_quotation.assert_not_called()