Example #1
0
def test_select_house_ok(service: CancelReservationInOdoo, context: Context,
                         house):
    service._houses_repo = Mock(get=Mock(return_value=Some(house)))

    result = service.select_house(context)
    assert is_successful(result)
    assert result.unwrap().house == house
Example #2
0
def test_select_house_error(service: CancelReservationInOdoo,
                            context: Context):
    service._houses_repo = Mock(get=Mock(side_effect=RuntimeError('ERR')))

    result = service.select_house(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'
Example #3
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()
Example #4
0
def test_select_house_fail(service: CancelReservationInOdoo, context: Context):
    service._houses_repo = Mock(get=Mock(return_value=Nothing))

    result = service.select_house(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_house