コード例 #1
0
def test_select_user_bot_fail(service: CancelReservationInOdoo,
                              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: CancelReservationInOdoo, 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: CancelReservationInOdoo,
                               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'