def test_success(service: CreateReservation, context: Context, house,
                 room_type, rate_plan, rate, cancellation_policy):
    reservation = Reservation(
        id=111,
        house_id=house.id,
        connection_id=None,
        source=ReservationSources.MANUAL,
        channel=None,
        channel_id='',
        checkin=context.request.checkin,
        checkout=context.request.checkout,
        booked_at=timezone.now(),
        status=ReservationStatuses.HOLD,
        is_verified=True,
    )
    service._houses_repo = Mock(get=Mock(return_value=Some(house)))
    service._roomtypes_repo = Mock(get=Mock(return_value=Some(room_type)))
    service._prices_repo = Mock(get_plan=Mock(return_value=Some(rate_plan)),
                                select_rates=Mock(return_value=[rate]))
    service._reservations_repo = Mock(
        save=Mock(
            return_value=(Some(attr.evolve(reservation, is_verified=False)),
                          True)),
        accept=Mock(return_value=Some(reservation)),
    )
    service._policies_repo = Mock(get=Mock(
        return_value=Some(cancellation_policy)))

    result = service.execute(house.id, context.request, context.user)
    assert is_successful(result), result.failure()
    assert result.unwrap() == attr.evolve(reservation, is_verified=True)
def test_missed_reservation_request(service: CreateReservation, house, user):
    result = service.execute(house.id, None, user)  # noqa
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_reservation