예제 #1
0
def test_select_user_bot_fail(service: UpdateReservationInOdoo,
                              context: Context, house):
    service._members_repo = Mock(get_bot_user=Mock(return_value=Nothing))
    context.house = house
    context.user_id = None

    result = service.select_user(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_user
예제 #2
0
def test_select_user_bot_ok(service: UpdateReservationInOdoo, context: Context,
                            house, user):
    service._members_repo = Mock(get_bot_user=Mock(return_value=Some(user)))
    context.house = house
    context.user_id = None

    result = service.select_user(context)
    assert is_successful(result)
    assert result.unwrap().user == user
예제 #3
0
def test_select_user_bot_error(service: UpdateReservationInOdoo,
                               context: Context, house):
    service._members_repo = Mock(get_bot_user=Mock(
        side_effect=RuntimeError('ERR')))
    context.house = house
    context.user_id = None

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