Exemplo n.º 1
0
def test_select_reservation_ok(service: CancelReservationInOdoo,
                               context: Context, house, reservation):
    service._reservations_repo = Mock(get=Mock(return_value=Some(reservation)))
    context.house = house

    result = service.select_reservation(context)
    assert is_successful(result)
    assert result.unwrap().reservation == reservation
Exemplo n.º 2
0
def test_select_reservation_fail(service: CancelReservationInOdoo,
                                 context: Context, house):
    service._reservations_repo = Mock(get=Mock(return_value=Nothing))
    context.house = house

    result = service.select_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_reservation
Exemplo n.º 3
0
def test_select_reservation_error(service: CancelReservationInOdoo,
                                  context: Context, house):
    service._reservations_repo = Mock(get=Mock(
        side_effect=RuntimeError('ERR')))
    context.house = house

    result = service.select_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
Exemplo n.º 4
0
def test_success(service: CancelReservationInOdoo, house, reservation, user):
    service._houses_repo = Mock(get=Mock(return_value=Some(house)))
    service._reservations_repo = Mock(get=Mock(return_value=Some(reservation)))
    service._members_repo = Mock(get_user_by_id=Mock(return_value=Some(user)))
    service.get_rpc_api = Mock(
        return_value=Mock(cancel_opportunity=Mock(return_value=None),
                          cancel_quotation=Mock(return_value=None)))

    result = service.execute(house.id, reservation.id, user_id=user.id)
    assert is_successful(result)
    assert result.unwrap()