def test_select_reservation_ok(service: UpdateRoomClose, 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().source == reservation
def test_select_reservation_fail(service: UpdateRoomClose, 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
def test_select_reservation_missed_pk(service: UpdateRoomClose, context: Context, house): context.house = house context.pk = None result = service.select_reservation(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.missed_reservation
def test_select_reservation_error(service: UpdateRoomClose, 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'