예제 #1
0
def test_lock_back_quotation_error(service: UpdateReservationInOdoo,
                                   context: Context, house, user, reservation):
    context.house = house
    context.user = user
    context.reservation = reservation
    context.is_need_update_quotation = True
    context.is_locked_quotation = True
    context.api = Mock(confirm_quotation=Mock(side_effect=RuntimeError('ERR')))

    result = service.lock_back_quotation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
예제 #2
0
def test_lock_back_quotation_ok(service: UpdateReservationInOdoo,
                                context: Context, house, user, reservation):
    context.house = house
    context.user = user
    context.reservation = reservation
    context.is_need_update_quotation = True
    context.is_locked_quotation = True
    context.api = Mock(confirm_quotation=Mock(return_value=None))

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

    context.api.confirm_quotation.assert_called_once_with(321)
예제 #3
0
def test_lock_back_quotation_wasnot_locked(service: UpdateReservationInOdoo,
                                           context: Context, house, user,
                                           reservation):
    context.house = house
    context.user = user
    context.reservation = reservation
    context.is_need_update_quotation = True
    context.is_locked_quotation = False
    context.api = Mock(confirm_quotation=Mock(side_effect=RuntimeError('ERR')))

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

    context.api.confirm_quotation.assert_not_called()