예제 #1
0
def test_update_group_no_group_for_update(identity_client):
    error_message = "No Group"
    module = get_module(dict(group_id="ocid1.group..xvdf"))
    try:
        oci_group.update_group(identity_client, None, module)
    except Exception as ex:
        assert error_message in str(ex.args)
예제 #2
0
def test_update_for_group_description_changed_success(
    mocker, identity_client, update_group_description_and_tags_patch
):
    additional_properties = dict(
        {"state": "present", "users": None, "compartment_id": "test_compartment"}
    )
    module = get_module(additional_properties)
    group = create_group_object()
    update_group_description_and_tags_patch.return_value = group, True
    changed, dummy = oci_group.update_group(identity_client, group, module)
    assert update_group_description_and_tags_patch.called
    assert changed is True
def test_update_user_changed_success(mocker, identity_client,
                                     oci_wait_until_patch,
                                     update_group_description_and_tags_patch,
                                     get_existing_group_members_patch):
    additional_properties = dict({'state': 'present', 'users': ['test_user']})
    mock_update_members = mocker.patch.object(oci_group, 'update_group_users')
    module = get_module(additional_properties)
    group = create_group_object()
    update_group_description_and_tags_patch.return_value = group, False
    mock_update_members.return_value = True
    changed, _ = oci_group.update_group(identity_client, group, module)
    assert mock_update_members.called
    assert changed is True
def test_update_for_group_description_changed_success(
        mocker, identity_client, update_group_description_and_tags_patch):
    additional_properties = dict({
        'state': 'present',
        'users': None,
        'compartment_id': 'test_compartment'
    })
    module = get_module(additional_properties)
    group = create_group_object()
    update_group_description_and_tags_patch.return_value = group, True
    changed, _ = oci_group.update_group(identity_client, group, module)
    assert update_group_description_and_tags_patch.called
    assert changed is True
예제 #5
0
def test_update_user_changed_no_user_success(
    mocker,
    identity_client,
    oci_wait_until_patch,
    update_group_description_and_tags_patch,
    get_existing_group_members_patch,
):
    additional_properties = dict({"state": "present", "users": []})
    mock_delete_user = mocker.patch.object(oci_group, "delete_all_users_from_group")
    module = get_module(additional_properties)
    group = create_group_object()
    update_group_description_and_tags_patch.return_value = group, False
    mock_delete_user.return_value = True
    changed, dummy = oci_group.update_group(identity_client, group, module)
    assert mock_delete_user.called
    assert changed is True