Exemplo n.º 1
0
def test_update_user_command__non_existing_user(mocker):
    args = {"user-profile": {"email": "*****@*****.**"}}
    mocker.patch.object(Client, 'get_access_token_', return_value='')
    client = mock_client()

    mocker.patch.object(client,
                        'get_user_id_and_activity_by_mail',
                        return_value=(None, None))
    mocker.patch.object(IAMUserProfile, 'map_object', return_value={})
    mocker.patch.object(client,
                        'create_user',
                        return_value=SALESFORCE_CREATE_USER_OUTPUT)

    iam_user_profile = update_user_command(client,
                                           args,
                                           'mapper_out',
                                           is_command_enabled=True,
                                           is_create_user_enabled=True,
                                           create_if_not_exists=True)
    outputs = get_outputs_from_user_profile(iam_user_profile)

    assert outputs.get('action') == IAMActions.CREATE_USER
    assert outputs.get('success') is True
    assert outputs.get('active') is True
    assert outputs.get('id') == '12345'
Exemplo n.º 2
0
def test_update_user_command__command_is_disabled(mocker):
    args = {"user-profile": {"email": "*****@*****.**"}}
    mocker.patch.object(Client, 'get_access_token_', return_value='')
    client = mock_client()

    mocker.patch.object(client,
                        'get_user_id_and_activity_by_mail',
                        return_value=(None, None))
    mocker.patch.object(IAMUserProfile, 'map_object', return_value={})
    mocker.patch.object(client, 'update_user')

    user_profile = update_user_command(client,
                                       args,
                                       'mapper_out',
                                       is_command_enabled=False,
                                       is_create_user_enabled=False,
                                       create_if_not_exists=False)
    outputs = get_outputs_from_user_profile(user_profile)

    assert outputs.get('action') == IAMActions.UPDATE_USER
    assert outputs.get('success') is True
    assert outputs.get('skipped') is True
    assert outputs.get('reason') == 'Command is disabled.'