Exemplo n.º 1
0
def test_select_user_fail(service: CancelReservationInOdoo, context: Context,
                          house):
    service._members_repo = Mock(get_user_by_id=Mock(return_value=Nothing))
    context.house = house

    result = service.select_user(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_user
Exemplo n.º 2
0
def test_select_user_ok(service: CancelReservationInOdoo, context: Context,
                        house, user):
    service._members_repo = Mock(get_user_by_id=Mock(return_value=Some(user)))
    context.house = house

    result = service.select_user(context)
    assert is_successful(result)
    assert result.unwrap().user == user
Exemplo n.º 3
0
def test_select_user_error(service: CancelReservationInOdoo, context: Context,
                           house):
    service._members_repo = Mock(get_user_by_id=Mock(
        side_effect=RuntimeError('ERR')))
    context.house = house

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