Ejemplo n.º 1
0
def test_save_reservation_other_guest(service: UpdateReservationGuest,
                                      context: Context, house, reservation):
    service._reservations_repo = Mock(save=Mock(
        side_effect=RuntimeError('ERR')))
    context.contact_id = 999
    context.house = house
    context.source = reservation
    context.reservation = reservation

    result = service.save_reservation(context)
    assert is_successful(result)
    assert result.unwrap().reservation == reservation
Ejemplo n.º 2
0
def test_save_reservation_fail(service: UpdateReservationGuest,
                               context: Context, house, reservation):
    service._reservations_repo = Mock(save=Mock(return_value=(Nothing, False)))
    context.house = house
    context.source = reservation
    context.reservation = reservation

    result = service.save_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert result.failure().error.startswith(
        'Error save guest information for Reservation ID=')
Ejemplo n.º 3
0
def test_save_reservation_ok(service: UpdateReservationGuest, context: Context,
                             house, reservation):
    _reservation = attr.evolve(reservation, guest_name='John')
    service._reservations_repo = Mock(save=Mock(
        return_value=(Some(_reservation), True)))
    context.house = house
    context.source = reservation
    context.reservation = reservation

    result = service.save_reservation(context)
    assert is_successful(result)
    assert result.unwrap().reservation == _reservation
Ejemplo n.º 4
0
def test_save_reservation_error(service: UpdateReservationGuest,
                                context: Context, house, reservation):
    service._reservations_repo = Mock(save=Mock(
        side_effect=RuntimeError('ERR')))
    context.house = house
    context.source = reservation
    context.reservation = reservation

    result = service.save_reservation(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'